Personal Telegram developer console for GitHub

feat: make Nexa Studio open in the Mini App with reviewed workspace approvals

Codex committed Oct 27, 2026 at 02:33 UTC 4291cb94618bf2d90ec391594736775eab544559
41 files changed +9846 -436
.gitignore
+1
@@ -4,3 +4,4 @@ node_modules/
4 .env
5 .env.*
6 .DS_Store
7 +web/dist/
.prettierignore new
+3
@@ -0,0 +1,3 @@
1 +node_modules/
2 +.wrangler/
3 +web/dist/
AGENTS.md
+2
@@ -1,5 +1,7 @@
1 # Nexa Studio working instructions
2
3 +- Latest owner correction (2026-10-26/27): entry must begin in the real Mini App, not Telegram repository/file menus. Continue the existing owner-only Worker with `web/`, CodeMirror, real repository APIs and existing signed Approval execution. Preserve this priority; an editor-only page is not the requested primary entry. This slice does not accept the remaining G0 evidence or the full G1/PAT migration gate.
4 +
5 - Latest owner direction (2026-10-25): continue real implementation here. Handoff files are continuity records, not a substitute for execution. Read `docs/roadmap/G0_HARDENING_2026_10_25.md` for the latest completed fixes and explicit remaining limits.
6
7 - Start with `docs/handoff/START_HERE.md` and the authoritative `docs/contract/NEXA_STUDIO_V3.md`. The original DOCX next to it wins over transcription differences. The proposed roadmap in PR #62 does not replace or weaken that contract.
PROJECT_MEMORY.md
+1
@@ -1,6 +1,7 @@
1 # PROJECT_MEMORY.md
2
3 ## Latest implementation checkpoint — 2026-10-25
4 +- Primary-entry correction (2026-10-26/27): owner requires the real Mini App from `/start`. `web/` React/TypeScript/CodeMirror app, authenticated Studio repository/tree/Workspace APIs, conditional saves/review+message CAS and existing Telegram Approval handoff implemented; see `docs/roadmap/MINIAPP_PRIMARY_ENTRY.md`. Node22 full492 tests/type/lint/format/web+Worker dry-run passed; actual local workerd/SQLite and Chromium mobile/desktop passed with provider stubs, not real owner-device evidence. Existing live cc7772d deployment remains historical until the PR records the corrected entry rollout. Full PAT/G1 and gate acceptance remain incomplete.
5 - Follow-up code head `515333d224a5cd9133023a479512fa0a458f9f25`: C-30 token deletion/revocation warning (new/edited text/captions), no Telegram Paste/upload source input, durable one-use TOTP steps across distinct Approvals, validated own-environment Editor links. Full Node22 suite **390 passed**, zero failures/skips; lint zero errors/13 existing warnings, formatting/dry-run pass. Actual local workerd/SQLite full Phase1 + signed Approval against outbound stubs passed across restart; not real owner/provider evidence. See latest section of the hardening report. Wrong-TOTP attempt increments remain an explicitly recorded P2 follow-up.
6 - Owner requested continued implementation in this environment. Delivery branch remains `feat/studio-g0-foundation`, PR #65; main baseline remains `5d1c083d326db327cc3973a9d3adecc1d8092c91`.
7 - Code head `e02e9fb976f11167aa04a842f881dedb3e11a3ef`: bounded exact Diff, durable Automation claims/CAS, transactional Incident updates, active-runtime/SHA correlation and workflow tagging, metadata-only Telegram source views plus authenticated read-only Mini App file/Diff reading.
README.md
+14 -12
@@ -31,18 +31,20 @@ V2.1 شامل Workspace Editor، Ops Console، Security Center، Configuration C
31
32 قرارداد توسعهٔ Nexa Studio نسخهٔ ۳ در [docs/contract/NEXA_STUDIO_V3.md](docs/contract/NEXA_STUDIO_V3.md) و فایل Word اصلی کنار آن نگهداری می‌شود. برچسب محصول V2.1 مربوط به بات موجود است؛ نسخهٔ انتشار کد از `package.json` خوانده می‌شود و با شمارهٔ قرارداد یکی نیست.
33
34 -جریان ویرایش فایل:
35 -
36 -1. `پروژه‌ها` → انتخاب Repository.
37 -2. `فایل‌ها` → انتخاب فایل متنی مجاز.
38 -3. `Edit` → Pin شدن **exact base SHA** و ساخت Workspace/Change Set.
39 -4. `Editor` → باز شدن Telegram Mini App.
40 -5. `ذخیره Draft` → فقط Draft داخل `WORKSPACE_STORE` به‌روزرسانی می‌شود.
41 -6. `Diff` → مقایسه Original و Draft.
42 -7. `پیام Commit` → ثبت پیام Commit.
43 -8. `آماده Commit` → اعتبارسنجی و ساخت Intent امن.
44 -9. `Safe Approval` → فقط بعد از «تأیید و اجرا» Provider WRITE مجاز می‌شود.
45 -10. Bot یک Commit و Branch مستقل `nexa/edit-*` می‌سازد؛ `main` مستقیم تغییر نمی‌کند.
34 +ورودی اصلی و جریان ویرایش:
35 +
36 +1. `/start` در بات → دکمهٔ **باز کردن Nexa Studio**. دکمهٔ منوی چت مالک نیز Mini App را باز می‌کند.
37 +2. داخل Mini App در `/studio/`: انتخاب مخزن واقعی و مرور فایل‌ها.
38 +3. انتخاب فایل متنی مجاز → Pin شدن **exact base SHA** و ساخت Workspace/Change Set.
39 +4. ویرایش چندفایلی در CodeMirror 6، جست‌وجو و Undo/Redo؛ کد LTR و برنامه فارسی RTL است.
40 +5. `ذخیره تغییرات` → فقط Draft در `WORKSPACE_STORE` با revision و `If-Match` ذخیره می‌شود؛ تضاد نسخه 409 و انتخاب صریح دارد.
41 +6. `بازبینی تغییرات` → نمایش Diff و ثبت پیام Commit در همان Mini App.
42 +7. `درخواست تأیید امن` → اتصال اتمیک تأیید به همان نسخهٔ فایل‌ها و همان پیام بررسی‌شده؛ تغییر هم‌زمان نیازمند بازبینی تازه است.
43 +8. تأیید نهایی از پیام امضاشدهٔ بات → Commit و Branch مستقل `nexa/edit-*`؛ `main` مستقیم تغییر نمی‌کند.
44 +
45 +برنامه پس از بازشدن دوباره می‌تواند فضای کار قبلی را از سرور ادامه دهد؛ فقط شناسهٔ تصادفی فضای کار روی دستگاه نگهداری می‌شود، نه کد یا توکن. این نسخه از دسترسی فعلی مالک استفاده می‌کند و ویزارد اتصال PAT، سشن و Grant چندکاربره یا پذیرش کامل G1 را پیاده‌سازی‌شده نمی‌داند.
46 +
47 +کد رابط در `web/` است و با `npm run build:web` در `web/dist` ساخته می‌شود؛ Static Assets از همان Worker و با CSP بدون `unsafe-inline` ارائه می‌شود. برای دامنهٔ سفارشی ورودی، `STUDIO_URL` باید HTTPS با مسیر `/studio/` و بدون query، fragment یا اطلاعات ورود باشد.
48
49 فایل‌های حساس، محتوای binary-like، Git LFS و موارد خارج از Policy قابل Edit نیستند.
50
docs/handoff/START_HERE.md
+2
@@ -1,5 +1,7 @@
1 # ادامهٔ کار Nexa Studio
2
3 +**اولویت جدید مالک — ۲۰۲۶/۱۰/۲۶–۲۷:** ورود اصلی باید از Mini App باشد. رابط واقعی `web/`، APIهای Studio، CodeMirror، ذخیرهٔ شرطی و تأیید متصل به بازبینی در [گزارش ورودی اصلی](../roadmap/MINIAPP_PRIMARY_ENTRY.md) ثبت شده‌اند. ۴۹۲ تست و آزمون محلی workerd/SQLite و Chromium موفق‌اند؛ وضعیت انتشار زنده و SHA دقیق را از PR65 بخوان. این اصلاح، پذیرش کامل G0/G1 یا تکمیل ویزارد PAT نیست.
4 +
5 هدف این تحویل: کارهای عادی و محدود در یک چت دیگر انجام شود؛ تغییرهای حساس به امنیت و داده با بازبینی متمرکز انجام شوند. از نو ممیزی کامل یا بازنویسی پروژه شروع نکن.
6
7 **تصمیم جدید مالک — ۲۰۲۶/۱۰/۲۵:** ادامهٔ پیاده‌سازی در همین محیط اجرایی انجام می‌شود. این راهنما فقط حافظهٔ ادامه است؛ تحویل دوبارهٔ پرامپت جای کار واقعی را نمی‌گیرد. آخرین تغییرات و محدودیت‌ها در [گزارش ادامهٔ G0](../roadmap/G0_HARDENING_2026_10_25.md) ثبت شده‌اند: ۳۹۰ تست محلی موفق، حذف ورودی کد تلگرام، رهگیری توکن پیام/ویرایش، مصرف پایدار یک‌بارهٔ TOTP و لینک Editor در محیط درست، همراه با اصلاحات Diff، Automation و Incident. آزمون کامل Phase1 با Approval امضاشده روی workerd/SQLite و سرویس‌های شبیه‌سازی‌شده موفق بود؛ شاهد دستگاه و ارائه‌دهندهٔ واقعی نیست.
docs/roadmap/MINIAPP_PRIMARY_ENTRY.md new
+31
@@ -0,0 +1,31 @@
1 +# Nexa Studio primary Mini App entry
2 +
3 +Owner correction, 2026-10-26/27: the app should start in the Mini App. The previous cc7772d release provided only an editor behind Telegram navigation. This change makes a real owner-only application entry on the same Worker; it is not full G1 acceptance.
4 +
5 +## Delivered behavior
6 +
7 +- `/start`, `/menu` and the main entry show a primary Nexa Studio Mini App button. `/start` removes the old keyboard and configures the validated owner's private-chat menu. Telegram requires a user gesture to open it; forced auto-launch is not claimed.
8 +- Real repository list with complete GitHub pagination; owner-scoped directory refs and pinned Workspace creation; Persian RTL React/TypeScript UI and CodeMirror6 with LTR source, tabs, search, undo/redo, sizing and actual server limits.
9 +- Authenticated draft editing, per-file revision/If-Match, explicit conflict choices, Diff and commit message inside the Mini App. No source or credential in local storage; recovery stores one opaque Workspace ID and revalidates owner access before displaying any state.
10 +- Approval request uses the existing signed Telegram Approval consumer and existing Kill Switch / replay / immutable intent. No GitHub mutation happens from browsing, saving or requesting approval.
11 +- Review binds exact base, file paths/revisions and displayed commit message at atomic seal time. Concurrent replacement requires fresh review. Approval issuance uses the exact sealed intent, not a later replacement.
12 +- DO transactions enforce file/state limits, prevent writes to committing/committed workspaces, and stop removed/readded path revisions from reusing stale values. Legacy editor calls advance revisions while retaining their existing API compatibility.
13 +- Actual Static Assets at `/studio/`, on the existing Worker, with fresh nonce for CodeMirror styles, external scripts/styles and no `unsafe-inline`. All Studio APIs validate fresh signed owner initData before provider/store access; responses and errors are bounded and metadata-safe.
14 +
15 +## Verification and evidence
16 +
17 +RED/GREEN reproduced missing entry/API/assets, conditional-save races, atomic size/count limits, stale review and commit-message substitution, cross-file client CAS and loss of recovery after closing the Mini App. Final integrated counts, exact SHA, CI and runtime/deployment identifiers are recorded on PR65 after final verification.
18 +
19 +Real local workerd/SQLite and Chromium checks use synthetic signed owners and intercepted local provider stubs. They are not Telegram owner-device recordings. No fake provider commit or owner acceptance may be inferred from them.
20 +
21 +Final integrated verification on Node 22.23.4: `npm ci`, lint zero errors / 13 existing warnings, Prettier, **492 tests passed with zero failed/skipped/cancelled**, TypeScript, production Vite and Wrangler 4.152.0 dry-run all passed. Two old `/start` integration fixtures were updated to the real private-chat shape and the new Studio entry expectations; authorization was not weakened.
22 +
23 +Actual local workerd/SQLite smoke passed: complete Studio API flow, revision and commit-message CAS, signed Approval, zero GitHub stub writes before approval, one branch-only commit through four local GitHubService requests, default branch unchanged, replay rejected before/after runtime restart. Chromium 154 exercised the built app against actual local Worker APIs at 390×844 and 1440×1000: zero CSP violations, page or console errors; CodeMirror nonce styles and typography worked; hostile-shaped source remained literal text; both layouts fit the viewport. No real provider/device evidence is claimed.
24 +
25 +Tested Worker bundle: 449,403 bytes; SHA-256 `e456cfe9b4052ca73e0f9e1d4506962aa95ca18e7460dbe8e44c168b49a30a1c`. Four Static Assets were built under `web/dist/studio`. Exact source commit, final CI, asset hashes and rollout identifiers are recorded on PR65 after push/deployment, avoiding a commit solely to record its own checks.
26 +
27 +## Explicit remaining scope
28 +
29 +This entry uses the owner's current runtime GitHub credential. Encrypted PAT onboarding/owner credential migration, multi-user sessions/grants/invites, per-user encrypted TOTP, D1 activity, complete G1 autosave/TTL requirements and the remaining gate evidence are not delivered by this entry correction. No placeholder cards or fake onboarding flow are exposed. The historical wrong-TOTP attempt-counter P2 follow-up remains separate.
30 +
31 +The original G0 device/real-Approval acceptance requirement and written gate decision remain pending. Main must stay unchanged. Live rollout, when recorded on PR65, is the correction to the already owner-authorized active bot, not permission to merge main or claim gate acceptance.
docs/superpowers/plans/2026-10-26-miniapp-entry.md new
+10
@@ -0,0 +1,10 @@
1 +# Mini App primary entry correction
2 +
3 +Owner correction: the application must start in the Telegram Mini App. The deployed cc7772d only had an embedded editor; chat navigation was not the requested entry. Continue autonomously on the existing Worker and owner-only access. This correction does not accept G0 or claim the full PAT/onboarding/G1 gate is complete.
4 +
5 +1. Add real authenticated owner APIs for home, complete repositories, directory navigation, pinned Workspace creation, editing, Diff, commit message and requesting the existing signed Telegram Approval. Provider writes stay exclusively in the existing Approval consumer/intent/Kill Switch flow.
6 +2. Add atomic per-file revisions and conditional saves so the new editor cannot silently overwrite concurrent edits. Existing legacy routes remain compatible and invalidate stale new-editor revisions.
7 +3. Build the Persian RTL Mini App in web/ using Vite/React/TypeScript/CodeMirror6, with literal source rendering, real loading/errors/empty states, file tabs, review and an explicit safe-approval handoff. No placeholder connection wizard or invented data.
8 +4. Serve actual Static Assets on the same Worker at /studio/, with nonce-based CodeMirror styles, external scripts/styles, no unsafe-inline and no authenticated data in cached HTML. Existing /workspace routes remain compatible.
9 +5. Make /start and the primary bot entry offer Nexa Studio immediately; configure the owner's chat menu button through the runtime Telegram client. Telegram requires a user gesture to launch; do not claim automatic forced opening.
10 +6. Run focused RED/GREEN, independent security/UI review, Node22 typecheck/lint/format/full tests and web/Worker builds; verify exact-head GitHub/Cloudflare checks. Publish the corrected entry within the owner's requested active-bot correction, preserving runtime secrets and all existing namespaces. Record exact code/asset identity and rollback metadata; never fabricate device evidence or G0 acceptance.
package-lock.json
+2123 -229
@@ -8,14 +8,47 @@
8 "name": "nexa-dev-bot",
9 "version": "1.1.1",
10 "license": "MIT",
11 + "dependencies": {
12 + "@codemirror/commands": "6.8.1",
13 + "@codemirror/lang-css": "6.3.1",
14 + "@codemirror/lang-html": "6.4.10",
15 + "@codemirror/lang-javascript": "6.2.4",
16 + "@codemirror/lang-json": "6.0.2",
17 + "@codemirror/language": "6.11.3",
18 + "@codemirror/search": "6.5.11",
19 + "@codemirror/state": "6.5.2",
20 + "@codemirror/view": "6.38.6",
21 + "react": "19.2.0",
22 + "react-dom": "19.2.0"
23 + },
24 "devDependencies": {
25 "@eslint/js": "10.0.1",
26 + "@types/react": "19.2.2",
27 + "@types/react-dom": "19.2.2",
28 + "esbuild": "0.28.2",
29 "eslint": "10.13.0",
30 "globals": "16.5.0",
31 + "jsdom": "26.1.0",
32 "prettier": "3.6.2",
33 + "typescript": "5.9.3",
34 + "vite": "7.2.2",
35 "wrangler": "4.152.0"
36 }
37 },
38 + "node_modules/@asamuzakjp/css-color": {
39 + "version": "3.2.0",
40 + "resolved": "https://registry.npmjs.org/@asamuzakjp/css-color/-/css-color-3.2.0.tgz",
41 + "integrity": "sha512-K1A6z8tS3XsmCMM86xoWdn7Fkdn9m6RSVtocUrJYIwZnFVkng/PvkEoWtOWmP+Scc6saYWHWZYbndEEXxl24jw==",
42 + "dev": true,
43 + "license": "MIT",
44 + "dependencies": {
45 + "@csstools/css-calc": "^2.1.3",
46 + "@csstools/css-color-parser": "^3.0.9",
47 + "@csstools/css-parser-algorithms": "^3.0.4",
48 + "@csstools/css-tokenizer": "^3.0.3",
49 + "lru-cache": "^10.4.3"
50 + }
51 + },
52 "node_modules/@cacheable/memory": {
53 "version": "2.2.0",
54 "resolved": "https://registry.npmjs.org/@cacheable/memory/-/memory-2.2.0.tgz",
@@ -151,6 +184,163 @@
184 "node": ">=16"
185 }
186 },
187 + "node_modules/@codemirror/autocomplete": {
188 + "version": "6.20.4",
189 + "resolved": "https://registry.npmjs.org/@codemirror/autocomplete/-/autocomplete-6.20.4.tgz",
190 + "integrity": "sha512-yF8RhOf2SXlg00+qtupzLhrglcas61boqaONiNcbPIebHCpJocpqTBA6dyrtUrQO47hqyTdeob/3XnYilT7TaQ==",
191 + "license": "MIT",
192 + "dependencies": {
193 + "@codemirror/language": "^6.0.0",
194 + "@codemirror/state": "^6.0.0",
195 + "@codemirror/view": "^6.17.0",
196 + "@lezer/common": "^1.0.0"
197 + }
198 + },
199 + "node_modules/@codemirror/commands": {
200 + "version": "6.8.1",
201 + "resolved": "https://registry.npmjs.org/@codemirror/commands/-/commands-6.8.1.tgz",
202 + "integrity": "sha512-KlGVYufHMQzxbdQONiLyGQDUW0itrLZwq3CcY7xpv9ZLRHqzkBSoteocBHtMCoY7/Ci4xhzSrToIeLg7FxHuaw==",
203 + "license": "MIT",
204 + "dependencies": {
205 + "@codemirror/language": "^6.0.0",
206 + "@codemirror/state": "^6.4.0",
207 + "@codemirror/view": "^6.27.0",
208 + "@lezer/common": "^1.1.0"
209 + }
210 + },
211 + "node_modules/@codemirror/lang-css": {
212 + "version": "6.3.1",
213 + "resolved": "https://registry.npmjs.org/@codemirror/lang-css/-/lang-css-6.3.1.tgz",
214 + "integrity": "sha512-kr5fwBGiGtmz6l0LSJIbno9QrifNMUusivHbnA1H6Dmqy4HZFte3UAICix1VuKo0lMPKQr2rqB+0BkKi/S3Ejg==",
215 + "license": "MIT",
216 + "dependencies": {
217 + "@codemirror/autocomplete": "^6.0.0",
218 + "@codemirror/language": "^6.0.0",
219 + "@codemirror/state": "^6.0.0",
220 + "@lezer/common": "^1.0.2",
221 + "@lezer/css": "^1.1.7"
222 + }
223 + },
224 + "node_modules/@codemirror/lang-html": {
225 + "version": "6.4.10",
226 + "resolved": "https://registry.npmjs.org/@codemirror/lang-html/-/lang-html-6.4.10.tgz",
227 + "integrity": "sha512-h/SceTVsN5r+WE+TVP2g3KDvNoSzbSrtZXCKo4vkKdbfT5t4otuVgngGdFukOO/rwRD2++pCxoh6xD4TEVMkQA==",
228 + "license": "MIT",
229 + "dependencies": {
230 + "@codemirror/autocomplete": "^6.0.0",
231 + "@codemirror/lang-css": "^6.0.0",
232 + "@codemirror/lang-javascript": "^6.0.0",
233 + "@codemirror/language": "^6.4.0",
234 + "@codemirror/state": "^6.0.0",
235 + "@codemirror/view": "^6.17.0",
236 + "@lezer/common": "^1.0.0",
237 + "@lezer/css": "^1.1.0",
238 + "@lezer/html": "^1.3.0"
239 + }
240 + },
241 + "node_modules/@codemirror/lang-javascript": {
242 + "version": "6.2.4",
243 + "resolved": "https://registry.npmjs.org/@codemirror/lang-javascript/-/lang-javascript-6.2.4.tgz",
244 + "integrity": "sha512-0WVmhp1QOqZ4Rt6GlVGwKJN3KW7Xh4H2q8ZZNGZaP6lRdxXJzmjm4FqvmOojVj6khWJHIb9sp7U/72W7xQgqAA==",
245 + "license": "MIT",
246 + "dependencies": {
247 + "@codemirror/autocomplete": "^6.0.0",
248 + "@codemirror/language": "^6.6.0",
249 + "@codemirror/lint": "^6.0.0",
250 + "@codemirror/state": "^6.0.0",
251 + "@codemirror/view": "^6.17.0",
252 + "@lezer/common": "^1.0.0",
253 + "@lezer/javascript": "^1.0.0"
254 + }
255 + },
256 + "node_modules/@codemirror/lang-json": {
257 + "version": "6.0.2",
258 + "resolved": "https://registry.npmjs.org/@codemirror/lang-json/-/lang-json-6.0.2.tgz",
259 + "integrity": "sha512-x2OtO+AvwEHrEwR0FyyPtfDUiloG3rnVTSZV1W8UteaLL8/MajQd8DpvUb2YVzC+/T18aSDv0H9mu+xw0EStoQ==",
260 + "license": "MIT",
261 + "dependencies": {
262 + "@codemirror/language": "^6.0.0",
263 + "@lezer/json": "^1.0.0"
264 + }
265 + },
266 + "node_modules/@codemirror/language": {
267 + "version": "6.11.3",
268 + "resolved": "https://registry.npmjs.org/@codemirror/language/-/language-6.11.3.tgz",
269 + "integrity": "sha512-9HBM2XnwDj7fnu0551HkGdrUrrqmYq/WC5iv6nbY2WdicXdGbhR/gfbZOH73Aqj4351alY1+aoG9rCNfiwS1RA==",
270 + "license": "MIT",
271 + "dependencies": {
272 + "@codemirror/state": "^6.0.0",
273 + "@codemirror/view": "^6.23.0",
274 + "@lezer/common": "^1.1.0",
275 + "@lezer/highlight": "^1.0.0",
276 + "@lezer/lr": "^1.0.0",
277 + "style-mod": "^4.0.0"
278 + }
279 + },
280 + "node_modules/@codemirror/lint": {
281 + "version": "6.9.7",
282 + "resolved": "https://registry.npmjs.org/@codemirror/lint/-/lint-6.9.7.tgz",
283 + "integrity": "sha512-28/+iWLYxKxsvGYhSYL7zaCZqLz5+FFFDq9tVsvGv9kv8RY4fFAchJ5WX9M3YrrRlTIsECjsXPqeNgnSmNP2dg==",
284 + "license": "MIT",
285 + "dependencies": {
286 + "@codemirror/state": "^6.0.0",
287 + "@codemirror/view": "^6.42.0",
288 + "crelt": "^1.0.5"
289 + }
290 + },
291 + "node_modules/@codemirror/lint/node_modules/@codemirror/state": {
292 + "version": "6.7.6",
293 + "resolved": "https://registry.npmjs.org/@codemirror/state/-/state-6.7.6.tgz",
294 + "integrity": "sha512-kAz+AncRtKuIknedxT1bq4XwXv4UowhbkHU1myPrtVb/jZtImWuV5BXzv5vK6i3kYACsdiZiQKFQQ5Mq7elW8w==",
295 + "license": "MIT",
296 + "dependencies": {
297 + "@marijn/find-cluster-break": "^1.0.0"
298 + }
299 + },
300 + "node_modules/@codemirror/lint/node_modules/@codemirror/view": {
301 + "version": "6.43.15",
302 + "resolved": "https://registry.npmjs.org/@codemirror/view/-/view-6.43.15.tgz",
303 + "integrity": "sha512-HHsfpqFeHyXLs983pSRe38Xajs0vFWZQ2BuX0m7Ki8w3jZ5iD8cuR3lBz2/5/X53Dhf32SBHKh6rtSTB6tKeGw==",
304 + "license": "MIT",
305 + "dependencies": {
306 + "@codemirror/state": "^6.7.0",
307 + "crelt": "^1.0.6",
308 + "style-mod": "^4.1.0",
309 + "w3c-keyname": "^2.2.4"
310 + }
311 + },
312 + "node_modules/@codemirror/search": {
313 + "version": "6.5.11",
314 + "resolved": "https://registry.npmjs.org/@codemirror/search/-/search-6.5.11.tgz",
315 + "integrity": "sha512-KmWepDE6jUdL6n8cAAqIpRmLPBZ5ZKnicE8oGU/s3QrAVID+0VhLFrzUucVKHG5035/BSykhExDL/Xm7dHthiA==",
316 + "license": "MIT",
317 + "dependencies": {
318 + "@codemirror/state": "^6.0.0",
319 + "@codemirror/view": "^6.0.0",
320 + "crelt": "^1.0.5"
321 + }
322 + },
323 + "node_modules/@codemirror/state": {
324 + "version": "6.5.2",
325 + "resolved": "https://registry.npmjs.org/@codemirror/state/-/state-6.5.2.tgz",
326 + "integrity": "sha512-FVqsPqtPWKVVL3dPSxy8wEF/ymIEuVzF1PK3VbUgrxXpJUSHQWWZz4JMToquRxnkw+36LTamCZG2iua2Ptq0fA==",
327 + "license": "MIT",
328 + "dependencies": {
329 + "@marijn/find-cluster-break": "^1.0.0"
330 + }
331 + },
332 + "node_modules/@codemirror/view": {
333 + "version": "6.38.6",
334 + "resolved": "https://registry.npmjs.org/@codemirror/view/-/view-6.38.6.tgz",
335 + "integrity": "sha512-qiS0z1bKs5WOvHIAC0Cybmv4AJSkAXgX5aD6Mqd2epSLlVJsQl8NG23jCVouIgkh4All/mrbdsf2UOLFnJw0tw==",
336 + "license": "MIT",
337 + "dependencies": {
338 + "@codemirror/state": "^6.5.0",
339 + "crelt": "^1.0.6",
340 + "style-mod": "^4.1.0",
341 + "w3c-keyname": "^2.2.4"
342 + }
343 + },
344 "node_modules/@cspotcode/source-map-support": {
345 "version": "0.8.1",
346 "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz",
@@ -164,6 +354,121 @@
354 "node": ">=12"
355 }
356 },
357 + "node_modules/@csstools/color-helpers": {
358 + "version": "5.1.0",
359 + "resolved": "https://registry.npmjs.org/@csstools/color-helpers/-/color-helpers-5.1.0.tgz",
360 + "integrity": "sha512-S11EXWJyy0Mz5SYvRmY8nJYTFFd1LCNV+7cXyAgQtOOuzb4EsgfqDufL+9esx72/eLhsRdGZwaldu/h+E4t4BA==",
361 + "dev": true,
362 + "funding": [
363 + {
364 + "type": "github",
365 + "url": "https://github.com/sponsors/csstools"
366 + },
367 + {
368 + "type": "opencollective",
369 + "url": "https://opencollective.com/csstools"
370 + }
371 + ],
372 + "license": "MIT-0",
373 + "engines": {
374 + "node": ">=18"
375 + }
376 + },
377 + "node_modules/@csstools/css-calc": {
378 + "version": "2.1.4",
379 + "resolved": "https://registry.npmjs.org/@csstools/css-calc/-/css-calc-2.1.4.tgz",
380 + "integrity": "sha512-3N8oaj+0juUw/1H3YwmDDJXCgTB1gKU6Hc/bB502u9zR0q2vd786XJH9QfrKIEgFlZmhZiq6epXl4rHqhzsIgQ==",
381 + "dev": true,
382 + "funding": [
383 + {
384 + "type": "github",
385 + "url": "https://github.com/sponsors/csstools"
386 + },
387 + {
388 + "type": "opencollective",
389 + "url": "https://opencollective.com/csstools"
390 + }
391 + ],
392 + "license": "MIT",
393 + "engines": {
394 + "node": ">=18"
395 + },
396 + "peerDependencies": {
397 + "@csstools/css-parser-algorithms": "^3.0.5",
398 + "@csstools/css-tokenizer": "^3.0.4"
399 + }
400 + },
401 + "node_modules/@csstools/css-color-parser": {
402 + "version": "3.1.0",
403 + "resolved": "https://registry.npmjs.org/@csstools/css-color-parser/-/css-color-parser-3.1.0.tgz",
404 + "integrity": "sha512-nbtKwh3a6xNVIp/VRuXV64yTKnb1IjTAEEh3irzS+HkKjAOYLTGNb9pmVNntZ8iVBHcWDA2Dof0QtPgFI1BaTA==",
405 + "dev": true,
406 + "funding": [
407 + {
408 + "type": "github",
409 + "url": "https://github.com/sponsors/csstools"
410 + },
411 + {
412 + "type": "opencollective",
413 + "url": "https://opencollective.com/csstools"
414 + }
415 + ],
416 + "license": "MIT",
417 + "dependencies": {
418 + "@csstools/color-helpers": "^5.1.0",
419 + "@csstools/css-calc": "^2.1.4"
420 + },
421 + "engines": {
422 + "node": ">=18"
423 + },
424 + "peerDependencies": {
425 + "@csstools/css-parser-algorithms": "^3.0.5",
426 + "@csstools/css-tokenizer": "^3.0.4"
427 + }
428 + },
429 + "node_modules/@csstools/css-parser-algorithms": {
430 + "version": "3.0.5",
431 + "resolved": "https://registry.npmjs.org/@csstools/css-parser-algorithms/-/css-parser-algorithms-3.0.5.tgz",
432 + "integrity": "sha512-DaDeUkXZKjdGhgYaHNJTV9pV7Y9B3b644jCLs9Upc3VeNGg6LWARAT6O+Q+/COo+2gg/bM5rhpMAtf70WqfBdQ==",
433 + "dev": true,
434 + "funding": [
435 + {
436 + "type": "github",
437 + "url": "https://github.com/sponsors/csstools"
438 + },
439 + {
440 + "type": "opencollective",
441 + "url": "https://opencollective.com/csstools"
442 + }
443 + ],
444 + "license": "MIT",
445 + "engines": {
446 + "node": ">=18"
447 + },
448 + "peerDependencies": {
449 + "@csstools/css-tokenizer": "^3.0.4"
450 + }
451 + },
452 + "node_modules/@csstools/css-tokenizer": {
453 + "version": "3.0.4",
454 + "resolved": "https://registry.npmjs.org/@csstools/css-tokenizer/-/css-tokenizer-3.0.4.tgz",
455 + "integrity": "sha512-Vd/9EVDiu6PPJt9yAh6roZP6El1xHrdvIVGjyBsHR0RYwNHgL7FJPyIIW4fANJNG6FtyZfvlRPpFI4ZM/lubvw==",
456 + "dev": true,
457 + "funding": [
458 + {
459 + "type": "github",
460 + "url": "https://github.com/sponsors/csstools"
461 + },
462 + {
463 + "type": "opencollective",
464 + "url": "https://opencollective.com/csstools"
465 + }
466 + ],
467 + "license": "MIT",
468 + "engines": {
469 + "node": ">=18"
470 + }
471 + },
472 "node_modules/@emnapi/runtime": {
473 "version": "1.11.3",
474 "resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-1.11.3.tgz",
@@ -1390,6 +1695,97 @@
1695 "dev": true,
1696 "license": "MIT"
1697 },
1698 + "node_modules/@lezer/common": {
1699 + "version": "1.5.4",
1700 + "resolved": "https://registry.npmjs.org/@lezer/common/-/common-1.5.4.tgz",
1701 + "integrity": "sha512-xt3Q4z64xM+xhg4M7NXqw1N//1O74bUFo5kz6fwMeC4qwxSuRdwkYSmjcqCEEKYkNw5e67f2hcNqBoNERAEU0w==",
1702 + "license": "MIT"
1703 + },
1704 + "node_modules/@lezer/css": {
1705 + "version": "1.3.9",
1706 + "resolved": "https://registry.npmjs.org/@lezer/css/-/css-1.3.9.tgz",
1707 + "integrity": "sha512-ZmzgvTOBdJWGIsY/ItAfN7UW8DV802oZG+jeG6E508SwEzz5YhuAajptpWPICvIyqYAD2+VjMdOS40GgGkyEOQ==",
1708 + "license": "MIT",
1709 + "dependencies": {
1710 + "@lezer/common": "^1.2.0",
1711 + "@lezer/highlight": "^1.0.0",
1712 + "@lezer/lr": "^1.3.0"
1713 + }
1714 + },
1715 + "node_modules/@lezer/highlight": {
1716 + "version": "1.2.5",
1717 + "resolved": "https://registry.npmjs.org/@lezer/highlight/-/highlight-1.2.5.tgz",
1718 + "integrity": "sha512-O1GMVKgtf5YspFaRzpmqkVgMtIk2HG9uMAbH6wdAIdNh3TVzCsch/+cRi+6l2//UGDKe6NB9BW3cvuR5ezMQ0w==",
1719 + "license": "MIT",
1720 + "dependencies": {
1721 + "@lezer/common": "^1.3.0"
1722 + }
1723 + },
1724 + "node_modules/@lezer/html": {
1725 + "version": "1.3.13",
1726 + "resolved": "https://registry.npmjs.org/@lezer/html/-/html-1.3.13.tgz",
1727 + "integrity": "sha512-oI7n6NJml729m7pjm9lvLvmXbdoMoi2f+1pwSDJkl9d68zGr7a9Btz8NdHTGQZtW2DA25ybeuv/SyDb9D5tseg==",
1728 + "license": "MIT",
1729 + "dependencies": {
1730 + "@lezer/common": "^1.2.0",
1731 + "@lezer/highlight": "^1.0.0",
1732 + "@lezer/lr": "^1.0.0"
1733 + }
1734 + },
1735 + "node_modules/@lezer/javascript": {
1736 + "version": "1.5.6",
1737 + "resolved": "https://registry.npmjs.org/@lezer/javascript/-/javascript-1.5.6.tgz",
1738 + "integrity": "sha512-sEvOqpl4vJQca0NugSQK02vQPbc5KrvoojnYGoqqFgFO0MtcYhwGiHKVEB+LuXYJnfyXo4QPA8ztbrEa4Fw5NA==",
1739 + "license": "MIT",
1740 + "dependencies": {
1741 + "@lezer/common": "^1.2.0",
1742 + "@lezer/highlight": "^1.1.3",
1743 + "@lezer/lr": "^1.3.0"
1744 + }
1745 + },
1746 + "node_modules/@lezer/json": {
1747 + "version": "1.0.3",
1748 + "resolved": "https://registry.npmjs.org/@lezer/json/-/json-1.0.3.tgz",
1749 + "integrity": "sha512-BP9KzdF9Y35PDpv04r0VeSTKDeox5vVr3efE7eBbx3r4s3oNLfunchejZhjArmeieBH+nVOpgIiBJpEAv8ilqQ==",
1750 + "license": "MIT",
1751 + "dependencies": {
1752 + "@lezer/common": "^1.2.0",
1753 + "@lezer/highlight": "^1.0.0",
1754 + "@lezer/lr": "^1.0.0"
1755 + }
1756 + },
1757 + "node_modules/@lezer/lr": {
1758 + "version": "1.4.11",
1759 + "resolved": "https://registry.npmjs.org/@lezer/lr/-/lr-1.4.11.tgz",
1760 + "integrity": "sha512-UwgZcl1R66H2hDzBrA7kWyYmX6s8p5TQ+e/t7CuvgCtBEPxbEPaHYHu+pJBvTvDotEJpuQkJjbXuHiw5Cixxgw==",
1761 + "license": "MIT",
1762 + "dependencies": {
1763 + "@lezer/common": "^1.0.0"
1764 + }
1765 + },
1766 + "node_modules/@marijn/find-cluster-break": {
1767 + "version": "1.0.4",
1768 + "resolved": "https://registry.npmjs.org/@marijn/find-cluster-break/-/find-cluster-break-1.0.4.tgz",
1769 + "integrity": "sha512-Wy0V7+SGUjnF9/TkiM1hKVDPj7jKXduPNboMVtHTA8dySMURWqfg/JZ9E2Sq8JgSJmkl7k7Qe9FLeMSrSraWmQ==",
1770 + "license": "MIT"
1771 + },
1772 + "node_modules/@napi-rs/lzma-linux-x64-gnu": {
1773 + "version": "1.5.1",
1774 + "resolved": "https://registry.npmjs.org/@napi-rs/lzma-linux-x64-gnu/-/lzma-linux-x64-gnu-1.5.1.tgz",
1775 + "integrity": "sha512-oTXEIha4SsuXdTA4Iyskj0kpdx2yVXdhd75c2v3xGrHFfVMsbhTPZU/nMPL4sWKo4pBHm3aucLaqGlF696dTyQ==",
1776 + "cpu": [
1777 + "x64"
1778 + ],
1779 + "dev": true,
1780 + "license": "MIT",
1781 + "optional": true,
1782 + "os": [
1783 + "linux"
1784 + ],
1785 + "engines": {
1786 + "node": "^22.20 || ^24.12 || >=25"
1787 + }
1788 + },
1789 "node_modules/@poppinss/colors": {
1790 "version": "4.1.6",
1791 "resolved": "https://registry.npmjs.org/@poppinss/colors/-/colors-4.1.6.tgz",
@@ -1432,79 +1828,459 @@
1828 "dev": true,
1829 "license": "MIT"
1830 },
1435 - "node_modules/@sindresorhus/is": {
1436 - "version": "7.2.0",
1437 - "resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-7.2.0.tgz",
1438 - "integrity": "sha512-P1Cz1dWaFfR4IR+U13mqqiGsLFf1KbayybWwdd2vfctdV6hDpUkgCY0nKOLLTMSoRd/jJNjtbqzf13K8DCCXQw==",
1831 + "node_modules/@rollup/rollup-android-arm-eabi": {
1832 + "version": "4.65.0",
1833 + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.65.0.tgz",
1834 + "integrity": "sha512-t2AnVba25baFdq7gczzS13JyVcdubLVbFX1X04mxrggDrTQPUXNv3XM0k9H1hr5tqvg7AVvtQ720QHAj0iYqhg==",
1835 + "cpu": [
1836 + "arm"
1837 + ],
1838 "dev": true,
1839 "license": "MIT",
1441 - "engines": {
1442 - "node": ">=18"
1443 - },
1444 - "funding": {
1445 - "url": "https://github.com/sindresorhus/is?sponsor=1"
1446 - }
1840 + "optional": true,
1841 + "os": [
1842 + "android"
1843 + ]
1844 },
1448 - "node_modules/@speed-highlight/core": {
1449 - "version": "1.2.24",
1450 - "resolved": "https://registry.npmjs.org/@speed-highlight/core/-/core-1.2.24.tgz",
1451 - "integrity": "sha512-qeW2e1l78afw8VhRPfPQ1Gjj+KU5XFQ/OFV5ti6eTa9bruO7mJyZtA4vw0ofqmA3tKCkROE9xLk3VZoeRc98nw==",
1845 + "node_modules/@rollup/rollup-android-arm64": {
1846 + "version": "4.65.0",
1847 + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.65.0.tgz",
1848 + "integrity": "sha512-dNONUaEwPGhl/nuO2KV8VABWlcjYyU6KtZGN8dQv5OS5JU7JSCxPijVNKXbRJd0iuTzTiJ4TjPt/4bbvDRNiMQ==",
1849 + "cpu": [
1850 + "arm64"
1851 + ],
1852 "dev": true,
1453 - "license": "CC0-1.0"
1853 + "license": "MIT",
1854 + "optional": true,
1855 + "os": [
1856 + "android"
1857 + ]
1858 },
1455 - "node_modules/@types/esrecurse": {
1456 - "version": "4.3.1",
1457 - "resolved": "https://registry.npmjs.org/@types/esrecurse/-/esrecurse-4.3.1.tgz",
1458 - "integrity": "sha512-xJBAbDifo5hpffDBuHl0Y8ywswbiAp/Wi7Y/GtAgSlZyIABppyurxVueOPE8LUQOxdlgi6Zqce7uoEpqNTeiUw==",
1859 + "node_modules/@rollup/rollup-darwin-arm64": {
1860 + "version": "4.65.0",
1861 + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.65.0.tgz",
1862 + "integrity": "sha512-zWQqUH+9zavr2Bxuzfpuv2SIF3X31cr58TvSQC9o1GhpOvkqRwr60GkZdQcudyT/BEgdpdSafjgd2I13MbTL7g==",
1863 + "cpu": [
1864 + "arm64"
1865 + ],
1866 "dev": true,
1460 - "license": "MIT"
1867 + "license": "MIT",
1868 + "optional": true,
1869 + "os": [
1870 + "darwin"
1871 + ]
1872 },
1462 - "node_modules/@types/estree": {
1463 - "version": "1.0.9",
1464 - "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.9.tgz",
1465 - "integrity": "sha512-GhdPgy1el4/ImP05X05Uw4cw2/M93BCUmnEvWZNStlCzEKME4Fkk+YpoA5OiHNQmoS7Cafb8Xa3Pya8m1Qrzeg==",
1873 + "node_modules/@rollup/rollup-darwin-x64": {
1874 + "version": "4.65.0",
1875 + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.65.0.tgz",
1876 + "integrity": "sha512-RQYreBFWtO4//hIuOaZkYUnF/lPU4lz35dveDimDshWCJvVisVtJ/shmT9bkXK8wFJY+FJF89X6F3Cq1qI3LCw==",
1877 + "cpu": [
1878 + "x64"
1879 + ],
1880 "dev": true,
1467 - "license": "MIT"
1881 + "license": "MIT",
1882 + "optional": true,
1883 + "os": [
1884 + "darwin"
1885 + ]
1886 },
1469 - "node_modules/@types/json-schema": {
1470 - "version": "7.0.15",
1471 - "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz",
1472 - "integrity": "sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==",
1887 + "node_modules/@rollup/rollup-freebsd-arm64": {
1888 + "version": "4.65.0",
1889 + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.65.0.tgz",
1890 + "integrity": "sha512-A0NfMj6Cuh/9BE5k3awJKv6HoxFVXIcLAb6SZqAMoxUHPA1ZNNK4RsGuUPD/vL7nEAm9LG+ZzXWWTrnC0XtkpA==",
1891 + "cpu": [
1892 + "arm64"
1893 + ],
1894 "dev": true,
1474 - "license": "MIT"
1895 + "license": "MIT",
1896 + "optional": true,
1897 + "os": [
1898 + "freebsd"
1899 + ]
1900 },
1476 - "node_modules/acorn": {
1477 - "version": "8.19.0",
1478 - "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.19.0.tgz",
1479 - "integrity": "sha512-oJlA3XiRm7Cyk6qFD2Jn8ak9B7jSy0qy00ADO3+8dpT0LSjFihQYv4C02LFCSYJV3Q37xYwwRy5m+IpIiUzqWw==",
1901 + "node_modules/@rollup/rollup-freebsd-x64": {
1902 + "version": "4.65.0",
1903 + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.65.0.tgz",
1904 + "integrity": "sha512-BI6/H7q3aP0I7S7GOrjyxTjgEJlSnovXE38+bdxBpuKN6z+d//uF+T+VQ3Q7ltJL/71p17ufartARX9Ja5gOGQ==",
1905 + "cpu": [
1906 + "x64"
1907 + ],
1908 "dev": true,
1909 "license": "MIT",
1482 - "bin": {
1483 - "acorn": "bin/acorn"
1484 - },
1485 - "engines": {
1486 - "node": ">=0.4.0"
1487 - }
1910 + "optional": true,
1911 + "os": [
1912 + "freebsd"
1913 + ]
1914 },
1489 - "node_modules/acorn-jsx": {
1490 - "version": "5.3.2",
1491 - "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz",
1492 - "integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==",
1915 + "node_modules/@rollup/rollup-linux-arm-gnueabihf": {
1916 + "version": "4.65.0",
1917 + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.65.0.tgz",
1918 + "integrity": "sha512-W1vUprf09RWaVWnsFP1vlUkEWJzTZlpObOEAYZXt9Fq0UVAOYEkeGr7wBX7McKqqIQskXdBnpiOMgwPujordgA==",
1919 + "cpu": [
1920 + "arm"
1921 + ],
1922 "dev": true,
1923 "license": "MIT",
1495 - "peerDependencies": {
1496 - "acorn": "^6.0.0 || ^7.0.0 || ^8.0.0"
1497 - }
1924 + "optional": true,
1925 + "os": [
1926 + "linux"
1927 + ]
1928 },
1499 - "node_modules/ajv": {
1500 - "version": "6.15.0",
1501 - "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.15.0.tgz",
1502 - "integrity": "sha512-fgFx7Hfoq60ytK2c7DhnF8jIvzYgOMxfugjLOSMHjLIPgenqa7S7oaagATUq99mV6IYvN2tRmC0wnTYX6iPbMw==",
1929 + "node_modules/@rollup/rollup-linux-arm-musleabihf": {
1930 + "version": "4.65.0",
1931 + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.65.0.tgz",
1932 + "integrity": "sha512-s8QTcZWgrl9haFzEGIqyE5BWyo89pFDGLMBFZ752WYxk8DJwNU/O1X6pZgPw829d9/sm6CCHyrMP3aurt76p1Q==",
1933 + "cpu": [
1934 + "arm"
1935 + ],
1936 "dev": true,
1937 "license": "MIT",
1505 - "dependencies": {
1506 - "fast-deep-equal": "^3.1.1",
1507 - "fast-json-stable-stringify": "^2.0.0",
1938 + "optional": true,
1939 + "os": [
1940 + "linux"
1941 + ]
1942 + },
1943 + "node_modules/@rollup/rollup-linux-arm64-gnu": {
1944 + "version": "4.65.0",
1945 + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.65.0.tgz",
1946 + "integrity": "sha512-ke1f6dLRzkqveyjjF2fkEwQYZvxHtNNwjegY8nJrwcO0Bdqr8CzFO/pKE0Bns13cx0qz2Ba2Y0Hs3dSwMdnHxA==",
1947 + "cpu": [
1948 + "arm64"
1949 + ],
1950 + "dev": true,
1951 + "license": "MIT",
1952 + "optional": true,
1953 + "os": [
1954 + "linux"
1955 + ]
1956 + },
1957 + "node_modules/@rollup/rollup-linux-arm64-musl": {
1958 + "version": "4.65.0",
1959 + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.65.0.tgz",
1960 + "integrity": "sha512-926SMeUcy4y18Rz/w2aJiUKOnyAnm6czg72bXkQEaeemsll+Wr0hnsjb2BGRpHvWgwAMYy5ACJCotbvfLCfj0A==",
1961 + "cpu": [
1962 + "arm64"
1963 + ],
1964 + "dev": true,
1965 + "license": "MIT",
1966 + "optional": true,
1967 + "os": [
1968 + "linux"
1969 + ]
1970 + },
1971 + "node_modules/@rollup/rollup-linux-loong64-gnu": {
1972 + "version": "4.65.0",
1973 + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-gnu/-/rollup-linux-loong64-gnu-4.65.0.tgz",
1974 + "integrity": "sha512-6T7JNRP1hc4hqF2dUsEoVLOt9K8tmODoCLldtQRYnrddGGQY8Gqe2pM/qMMUo7EMowpP7oa2N95k0/8sYK/ipw==",
1975 + "cpu": [
1976 + "loong64"
1977 + ],
1978 + "dev": true,
1979 + "license": "MIT",
1980 + "optional": true,
1981 + "os": [
1982 + "linux"
1983 + ]
1984 + },
1985 + "node_modules/@rollup/rollup-linux-loong64-musl": {
1986 + "version": "4.65.0",
1987 + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-musl/-/rollup-linux-loong64-musl-4.65.0.tgz",
1988 + "integrity": "sha512-SImGFl1Je5kpyAgOCPONVT7h6ASV8mAUwGRjY7eZvVjPg//PfHOXgI+P241RF/+HqsA4PP3qD527ysWFKNQyhQ==",
1989 + "cpu": [
1990 + "loong64"
1991 + ],
1992 + "dev": true,
1993 + "license": "MIT",
1994 + "optional": true,
1995 + "os": [
1996 + "linux"
1997 + ]
1998 + },
1999 + "node_modules/@rollup/rollup-linux-ppc64-gnu": {
2000 + "version": "4.65.0",
2001 + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-gnu/-/rollup-linux-ppc64-gnu-4.65.0.tgz",
2002 + "integrity": "sha512-XeDTbmPF1Yu5asfXGPrMkWoxTDhgryQbmw5Q1+R582O51VNCk23J6f2pDrsAp5YkneBVBwtExx6ZGOb9D2aQ6A==",
2003 + "cpu": [
2004 + "ppc64"
2005 + ],
2006 + "dev": true,
2007 + "license": "MIT",
2008 + "optional": true,
2009 + "os": [
2010 + "linux"
2011 + ]
2012 + },
2013 + "node_modules/@rollup/rollup-linux-ppc64-musl": {
2014 + "version": "4.65.0",
2015 + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-musl/-/rollup-linux-ppc64-musl-4.65.0.tgz",
2016 + "integrity": "sha512-VS55JUI/1nsljmV/jfqNkLZXFw8uMO8nNlfoHmSevNf6fO3neuhyDvx9dv3c/Ytt8r/431SL8Qax1dpYvOMZTg==",
2017 + "cpu": [
2018 + "ppc64"
2019 + ],
2020 + "dev": true,
2021 + "license": "MIT",
2022 + "optional": true,
2023 + "os": [
2024 + "linux"
2025 + ]
2026 + },
2027 + "node_modules/@rollup/rollup-linux-riscv64-gnu": {
2028 + "version": "4.65.0",
2029 + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.65.0.tgz",
2030 + "integrity": "sha512-Vblw84TbX7RS4la1Y4+yQ7aore/oSyaNtFbppuBr5Vs/4LfBeXKq9dIfoExw6zOvRERqd2rRAjnZRaMhH/0x5w==",
2031 + "cpu": [
2032 + "riscv64"
2033 + ],
2034 + "dev": true,
2035 + "license": "MIT",
2036 + "optional": true,
2037 + "os": [
2038 + "linux"
2039 + ]
2040 + },
2041 + "node_modules/@rollup/rollup-linux-riscv64-musl": {
2042 + "version": "4.65.0",
2043 + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-musl/-/rollup-linux-riscv64-musl-4.65.0.tgz",
2044 + "integrity": "sha512-7+gHjtONvKgwR9InTKFaLq53f6YzBJkgeMRBENdWTsQr+spahGqQm8HF5aXpq8i4JaRrOqYyv6Zn1WltDTxaZQ==",
2045 + "cpu": [
2046 + "riscv64"
2047 + ],
2048 + "dev": true,
2049 + "license": "MIT",
2050 + "optional": true,
2051 + "os": [
2052 + "linux"
2053 + ]
2054 + },
2055 + "node_modules/@rollup/rollup-linux-s390x-gnu": {
2056 + "version": "4.65.0",
2057 + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.65.0.tgz",
2058 + "integrity": "sha512-KvNDC0J6s4vVHhtJ6KrDXU0Er0au/hmRIBq/+1maCV8TseGupeKizq0bWcrbp2HE1T8xoknvN0Q/KZ/YF0qX3w==",
2059 + "cpu": [
2060 + "s390x"
2061 + ],
2062 + "dev": true,
2063 + "license": "MIT",
2064 + "optional": true,
2065 + "os": [
2066 + "linux"
2067 + ]
2068 + },
2069 + "node_modules/@rollup/rollup-linux-x64-gnu": {
2070 + "version": "4.65.0",
2071 + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.65.0.tgz",
2072 + "integrity": "sha512-GExdD15WPvu/x/drELjVam7vX8EsPgvTMOa/iJL/p/4m/oOqzbb7JXZg8fXR4hlXtg/sF2zyTZ3bR0AEtEMlhQ==",
2073 + "cpu": [
2074 + "x64"
2075 + ],
2076 + "dev": true,
2077 + "license": "MIT",
2078 + "optional": true,
2079 + "os": [
2080 + "linux"
2081 + ]
2082 + },
2083 + "node_modules/@rollup/rollup-linux-x64-musl": {
2084 + "version": "4.65.0",
2085 + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.65.0.tgz",
2086 + "integrity": "sha512-8sT9PemIZfIMED4Vd4KGoOXVDj5CMSWNcGdbheRUx9TYS03yOWdT2Q0lXPyEyNBB9YTilwewIQKNIBk6Nxi0Kg==",
2087 + "cpu": [
2088 + "x64"
2089 + ],
2090 + "dev": true,
2091 + "license": "MIT",
2092 + "optional": true,
2093 + "os": [
2094 + "linux"
2095 + ]
2096 + },
2097 + "node_modules/@rollup/rollup-openbsd-x64": {
2098 + "version": "4.65.0",
2099 + "resolved": "https://registry.npmjs.org/@rollup/rollup-openbsd-x64/-/rollup-openbsd-x64-4.65.0.tgz",
2100 + "integrity": "sha512-pO6Ehi0jo5yE0R6PltKhJhv9mlIiyzBJk5N5NUF2OF6xtVKI+1bdXxj/rb0jGXy3hck1ELVT0QPY3tzkAm360w==",
2101 + "cpu": [
2102 + "x64"
2103 + ],
2104 + "dev": true,
2105 + "license": "MIT",
2106 + "optional": true,
2107 + "os": [
2108 + "openbsd"
2109 + ]
2110 + },
2111 + "node_modules/@rollup/rollup-openharmony-arm64": {
2112 + "version": "4.65.0",
2113 + "resolved": "https://registry.npmjs.org/@rollup/rollup-openharmony-arm64/-/rollup-openharmony-arm64-4.65.0.tgz",
2114 + "integrity": "sha512-vo7N3/+cjjPDYr8vtxC+qSNgWa9sDvJ7g8N8R5SWqFY4WiNH1ULcAU70SKVyHeiIZOYYwNP9pTipmhN5sl1NPw==",
2115 + "cpu": [
2116 + "arm64"
2117 + ],
2118 + "dev": true,
2119 + "license": "MIT",
2120 + "optional": true,
2121 + "os": [
2122 + "openharmony"
2123 + ]
2124 + },
2125 + "node_modules/@rollup/rollup-win32-arm64-msvc": {
2126 + "version": "4.65.0",
2127 + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.65.0.tgz",
2128 + "integrity": "sha512-ArwvgFAbjKcDM7qqotZ4OVYf+UMT9xH2YzkCzK4+AuZSDihMlz1Ekoe4INwBVXzn2mnJzuIYOcSx07iTBijGRQ==",
2129 + "cpu": [
2130 + "arm64"
2131 + ],
2132 + "dev": true,
2133 + "license": "MIT",
2134 + "optional": true,
2135 + "os": [
2136 + "win32"
2137 + ]
2138 + },
2139 + "node_modules/@rollup/rollup-win32-ia32-msvc": {
2140 + "version": "4.65.0",
2141 + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.65.0.tgz",
2142 + "integrity": "sha512-QGMmK4/cxKE/36FoLMSHQBCyymv/eFTnsCvvsBF0rgmOvVbvX78VWZRerL3dHa77f4pM6Xcc2iGDhJ10w/svKQ==",
2143 + "cpu": [
2144 + "ia32"
2145 + ],
2146 + "dev": true,
2147 + "license": "MIT",
2148 + "optional": true,
2149 + "os": [
2150 + "win32"
2151 + ]
2152 + },
2153 + "node_modules/@rollup/rollup-win32-x64-gnu": {
2154 + "version": "4.65.0",
2155 + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-gnu/-/rollup-win32-x64-gnu-4.65.0.tgz",
2156 + "integrity": "sha512-XfKYFWHIPs4HPODIMsGF1IKlS3H1e3WokUZIgpmn4+uNnZBlnRDDHEylNyazbQXwhMKZre68OjtRYbKqb5+j8w==",
2157 + "cpu": [
2158 + "x64"
2159 + ],
2160 + "dev": true,
2161 + "license": "MIT",
2162 + "optional": true,
2163 + "os": [
2164 + "win32"
2165 + ]
2166 + },
2167 + "node_modules/@rollup/rollup-win32-x64-msvc": {
2168 + "version": "4.65.0",
2169 + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.65.0.tgz",
2170 + "integrity": "sha512-wPWi++K4Bs1VR4XihOhfGi4IGX6Cub7FlerTf8X2v+2BtDHddgSqWCXwGD+h2yAe4/niIhNDwAltioOC+wEogQ==",
2171 + "cpu": [
2172 + "x64"
2173 + ],
2174 + "dev": true,
2175 + "license": "MIT",
2176 + "optional": true,
2177 + "os": [
2178 + "win32"
2179 + ]
2180 + },
2181 + "node_modules/@sindresorhus/is": {
2182 + "version": "7.2.0",
2183 + "resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-7.2.0.tgz",
2184 + "integrity": "sha512-P1Cz1dWaFfR4IR+U13mqqiGsLFf1KbayybWwdd2vfctdV6hDpUkgCY0nKOLLTMSoRd/jJNjtbqzf13K8DCCXQw==",
2185 + "dev": true,
2186 + "license": "MIT",
2187 + "engines": {
2188 + "node": ">=18"
2189 + },
2190 + "funding": {
2191 + "url": "https://github.com/sindresorhus/is?sponsor=1"
2192 + }
2193 + },
2194 + "node_modules/@speed-highlight/core": {
2195 + "version": "1.2.24",
2196 + "resolved": "https://registry.npmjs.org/@speed-highlight/core/-/core-1.2.24.tgz",
2197 + "integrity": "sha512-qeW2e1l78afw8VhRPfPQ1Gjj+KU5XFQ/OFV5ti6eTa9bruO7mJyZtA4vw0ofqmA3tKCkROE9xLk3VZoeRc98nw==",
2198 + "dev": true,
2199 + "license": "CC0-1.0"
2200 + },
2201 + "node_modules/@types/esrecurse": {
2202 + "version": "4.3.1",
2203 + "resolved": "https://registry.npmjs.org/@types/esrecurse/-/esrecurse-4.3.1.tgz",
2204 + "integrity": "sha512-xJBAbDifo5hpffDBuHl0Y8ywswbiAp/Wi7Y/GtAgSlZyIABppyurxVueOPE8LUQOxdlgi6Zqce7uoEpqNTeiUw==",
2205 + "dev": true,
2206 + "license": "MIT"
2207 + },
2208 + "node_modules/@types/estree": {
2209 + "version": "1.0.9",
2210 + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.9.tgz",
2211 + "integrity": "sha512-GhdPgy1el4/ImP05X05Uw4cw2/M93BCUmnEvWZNStlCzEKME4Fkk+YpoA5OiHNQmoS7Cafb8Xa3Pya8m1Qrzeg==",
2212 + "dev": true,
2213 + "license": "MIT"
2214 + },
2215 + "node_modules/@types/json-schema": {
2216 + "version": "7.0.15",
2217 + "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz",
2218 + "integrity": "sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==",
2219 + "dev": true,
2220 + "license": "MIT"
2221 + },
2222 + "node_modules/@types/react": {
2223 + "version": "19.2.2",
2224 + "resolved": "https://registry.npmjs.org/@types/react/-/react-19.2.2.tgz",
2225 + "integrity": "sha512-6mDvHUFSjyT2B2yeNx2nUgMxh9LtOWvkhIU3uePn2I2oyNymUAX1NIsdgviM4CH+JSrp2D2hsMvJOkxY+0wNRA==",
2226 + "dev": true,
2227 + "license": "MIT",
2228 + "dependencies": {
2229 + "csstype": "^3.0.2"
2230 + }
2231 + },
2232 + "node_modules/@types/react-dom": {
2233 + "version": "19.2.2",
2234 + "resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-19.2.2.tgz",
2235 + "integrity": "sha512-9KQPoO6mZCi7jcIStSnlOWn2nEF3mNmyr3rIAsGnAbQKYbRLyqmeSc39EVgtxXVia+LMT8j3knZLAZAh+xLmrw==",
2236 + "dev": true,
2237 + "license": "MIT",
2238 + "peerDependencies": {
2239 + "@types/react": "^19.2.0"
2240 + }
2241 + },
2242 + "node_modules/acorn": {
2243 + "version": "8.19.0",
2244 + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.19.0.tgz",
2245 + "integrity": "sha512-oJlA3XiRm7Cyk6qFD2Jn8ak9B7jSy0qy00ADO3+8dpT0LSjFihQYv4C02LFCSYJV3Q37xYwwRy5m+IpIiUzqWw==",
2246 + "dev": true,
2247 + "license": "MIT",
2248 + "bin": {
2249 + "acorn": "bin/acorn"
2250 + },
2251 + "engines": {
2252 + "node": ">=0.4.0"
2253 + }
2254 + },
2255 + "node_modules/acorn-jsx": {
2256 + "version": "5.3.2",
2257 + "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz",
2258 + "integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==",
2259 + "dev": true,
2260 + "license": "MIT",
2261 + "peerDependencies": {
2262 + "acorn": "^6.0.0 || ^7.0.0 || ^8.0.0"
2263 + }
2264 + },
2265 + "node_modules/agent-base": {
2266 + "version": "7.1.4",
2267 + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.4.tgz",
2268 + "integrity": "sha512-MnA+YT8fwfJPgBx3m60MNqakm30XOkyIoH1y6huTQvC0PwZG7ki8NacLBcrPbNoo8vEZy7Jpuk7+jMO+CUovTQ==",
2269 + "dev": true,
2270 + "license": "MIT",
2271 + "engines": {
2272 + "node": ">= 14"
2273 + }
2274 + },
2275 + "node_modules/ajv": {
2276 + "version": "6.15.0",
2277 + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.15.0.tgz",
2278 + "integrity": "sha512-fgFx7Hfoq60ytK2c7DhnF8jIvzYgOMxfugjLOSMHjLIPgenqa7S7oaagATUq99mV6IYvN2tRmC0wnTYX6iPbMw==",
2279 + "dev": true,
2280 + "license": "MIT",
2281 + "dependencies": {
2282 + "fast-deep-equal": "^3.1.1",
2283 + "fast-json-stable-stringify": "^2.0.0",
2284 "json-schema-traverse": "^0.4.1",
2285 "uri-js": "^4.2.2"
2286 },
@@ -1571,6 +2347,12 @@
2347 "url": "https://opencollective.com/express"
2348 }
2349 },
2350 + "node_modules/crelt": {
2351 + "version": "1.0.7",
2352 + "resolved": "https://registry.npmjs.org/crelt/-/crelt-1.0.7.tgz",
2353 + "integrity": "sha512-aK6BbWfhf4U/wCcLHKPJl/xa6VkVstRaPywWtMKGwuOLc/wZTyQYuoxgvZnNsBvv7Kg3YTBQYYBCggcviQczuA==",
2354 + "license": "MIT"
2355 + },
2356 "node_modules/cross-spawn": {
2357 "version": "7.0.6",
2358 "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz",
@@ -1586,24 +2368,66 @@
2368 "node": ">= 8"
2369 }
2370 },
1589 - "node_modules/debug": {
1590 - "version": "4.4.3",
1591 - "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz",
1592 - "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==",
2371 + "node_modules/cssstyle": {
2372 + "version": "4.6.0",
2373 + "resolved": "https://registry.npmjs.org/cssstyle/-/cssstyle-4.6.0.tgz",
2374 + "integrity": "sha512-2z+rWdzbbSZv6/rhtvzvqeZQHrBaqgogqt85sqFNbabZOuFbCVFb8kPeEtZjiKkbrm395irpNKiYeFeLiQnFPg==",
2375 "dev": true,
2376 "license": "MIT",
2377 "dependencies": {
1596 - "ms": "^2.1.3"
2378 + "@asamuzakjp/css-color": "^3.2.0",
2379 + "rrweb-cssom": "^0.8.0"
2380 },
2381 "engines": {
1599 - "node": ">=6.0"
1600 - },
1601 - "peerDependenciesMeta": {
1602 - "supports-color": {
2382 + "node": ">=18"
2383 + }
2384 + },
2385 + "node_modules/csstype": {
2386 + "version": "3.2.3",
2387 + "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.2.3.tgz",
2388 + "integrity": "sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ==",
2389 + "dev": true,
2390 + "license": "MIT"
2391 + },
2392 + "node_modules/data-urls": {
2393 + "version": "5.0.0",
2394 + "resolved": "https://registry.npmjs.org/data-urls/-/data-urls-5.0.0.tgz",
2395 + "integrity": "sha512-ZYP5VBHshaDAiVZxjbRVcFJpc+4xGgT0bK3vzy1HLN8jTO975HEbuYzZJcHoQEY5K1a0z8YayJkyVETa08eNTg==",
2396 + "dev": true,
2397 + "license": "MIT",
2398 + "dependencies": {
2399 + "whatwg-mimetype": "^4.0.0",
2400 + "whatwg-url": "^14.0.0"
2401 + },
2402 + "engines": {
2403 + "node": ">=18"
2404 + }
2405 + },
2406 + "node_modules/debug": {
2407 + "version": "4.4.3",
2408 + "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz",
2409 + "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==",
2410 + "dev": true,
2411 + "license": "MIT",
2412 + "dependencies": {
2413 + "ms": "^2.1.3"
2414 + },
2415 + "engines": {
2416 + "node": ">=6.0"
2417 + },
2418 + "peerDependenciesMeta": {
2419 + "supports-color": {
2420 "optional": true
2421 }
2422 }
2423 },
2424 + "node_modules/decimal.js": {
2425 + "version": "10.6.0",
2426 + "resolved": "https://registry.npmjs.org/decimal.js/-/decimal.js-10.6.0.tgz",
2427 + "integrity": "sha512-YpgQiITW3JXGntzdUmyUR1V812Hn8T1YVXhCu+wO3OpS4eU9l4YdD3qjyiKdV6mvV29zapkMeD390UVEf2lkUg==",
2428 + "dev": true,
2429 + "license": "MIT"
2430 + },
2431 "node_modules/deep-is": {
2432 "version": "0.1.4",
2433 "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz",
@@ -1621,6 +2445,19 @@
2445 "node": ">=8"
2446 }
2447 },
2448 + "node_modules/entities": {
2449 + "version": "6.0.1",
2450 + "resolved": "https://registry.npmjs.org/entities/-/entities-6.0.1.tgz",
2451 + "integrity": "sha512-aN97NXWF6AWBTahfVOIrB/NShkzi5H7F9r1s9mD3cDj4Ko5f2qhhVoYMibXF7GlLveb/D2ioWay8lxI97Ven3g==",
2452 + "dev": true,
2453 + "license": "BSD-2-Clause",
2454 + "engines": {
2455 + "node": ">=0.12"
2456 + },
2457 + "funding": {
2458 + "url": "https://github.com/fb55/entities?sponsor=1"
2459 + }
2460 + },
2461 "node_modules/error-stack-parser-es": {
2462 "version": "1.0.5",
2463 "resolved": "https://registry.npmjs.org/error-stack-parser-es/-/error-stack-parser-es-1.0.5.tgz",
@@ -1862,6 +2699,24 @@
2699 "dev": true,
2700 "license": "MIT"
2701 },
2702 + "node_modules/fdir": {
2703 + "version": "6.5.0",
2704 + "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz",
2705 + "integrity": "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==",
2706 + "dev": true,
2707 + "license": "MIT",
2708 + "engines": {
2709 + "node": ">=12.0.0"
2710 + },
2711 + "peerDependencies": {
2712 + "picomatch": "^3 || ^4"
2713 + },
2714 + "peerDependenciesMeta": {
2715 + "picomatch": {
2716 + "optional": true
2717 + }
2718 + }
2719 + },
2720 "node_modules/file-entry-cache": {
2721 "version": "11.1.5",
2722 "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-11.1.5.tgz",
@@ -1969,6 +2824,60 @@
2824 "dev": true,
2825 "license": "MIT"
2826 },
2827 + "node_modules/html-encoding-sniffer": {
2828 + "version": "4.0.0",
2829 + "resolved": "https://registry.npmjs.org/html-encoding-sniffer/-/html-encoding-sniffer-4.0.0.tgz",
2830 + "integrity": "sha512-Y22oTqIU4uuPgEemfz7NDJz6OeKf12Lsu+QC+s3BVpda64lTiMYCyGwg5ki4vFxkMwQdeZDl2adZoqUgdFuTgQ==",
2831 + "dev": true,
2832 + "license": "MIT",
2833 + "dependencies": {
2834 + "whatwg-encoding": "^3.1.1"
2835 + },
2836 + "engines": {
2837 + "node": ">=18"
2838 + }
2839 + },
2840 + "node_modules/http-proxy-agent": {
2841 + "version": "7.0.2",
2842 + "resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-7.0.2.tgz",
2843 + "integrity": "sha512-T1gkAiYYDWYx3V5Bmyu7HcfcvL7mUrTWiM6yOfa3PIphViJ/gFPbvidQ+veqSOHci/PxBcDabeUNCzpOODJZig==",
2844 + "dev": true,
2845 + "license": "MIT",
2846 + "dependencies": {
2847 + "agent-base": "^7.1.0",
2848 + "debug": "^4.3.4"
2849 + },
2850 + "engines": {
2851 + "node": ">= 14"
2852 + }
2853 + },
2854 + "node_modules/https-proxy-agent": {
2855 + "version": "7.0.6",
2856 + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-7.0.6.tgz",
2857 + "integrity": "sha512-vK9P5/iUfdl95AI+JVyUuIcVtd4ofvtrOr3HNtM2yxC9bnMbEdp3x01OhQNnjb8IJYi38VlTE3mBXwcfvywuSw==",
2858 + "dev": true,
2859 + "license": "MIT",
2860 + "dependencies": {
2861 + "agent-base": "^7.1.2",
2862 + "debug": "4"
2863 + },
2864 + "engines": {
2865 + "node": ">= 14"
2866 + }
2867 + },
2868 + "node_modules/iconv-lite": {
2869 + "version": "0.6.3",
2870 + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz",
2871 + "integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==",
2872 + "dev": true,
2873 + "license": "MIT",
2874 + "dependencies": {
2875 + "safer-buffer": ">= 2.1.2 < 3.0.0"
2876 + },
2877 + "engines": {
2878 + "node": ">=0.10.0"
2879 + }
2880 + },
2881 "node_modules/ignore": {
2882 "version": "5.3.2",
2883 "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.2.tgz",
@@ -2012,6 +2921,13 @@
2921 "node": ">=0.10.0"
2922 }
2923 },
2924 + "node_modules/is-potential-custom-element-name": {
2925 + "version": "1.0.1",
2926 + "resolved": "https://registry.npmjs.org/is-potential-custom-element-name/-/is-potential-custom-element-name-1.0.1.tgz",
2927 + "integrity": "sha512-bCYeRA2rVibKZd+s2625gGnGF/t7DSqDs4dP7CrLA1m7jKWz6pps0LpYLJN8Q64HtmPKJ1hrN3nzPNKFEKOUiQ==",
2928 + "dev": true,
2929 + "license": "MIT"
2930 + },
2931 "node_modules/isexe": {
2932 "version": "2.0.0",
2933 "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz",
@@ -2019,6 +2935,46 @@
2935 "dev": true,
2936 "license": "ISC"
2937 },
2938 + "node_modules/jsdom": {
2939 + "version": "26.1.0",
2940 + "resolved": "https://registry.npmjs.org/jsdom/-/jsdom-26.1.0.tgz",
2941 + "integrity": "sha512-Cvc9WUhxSMEo4McES3P7oK3QaXldCfNWp7pl2NNeiIFlCoLr3kfq9kb1fxftiwk1FLV7CvpvDfonxtzUDeSOPg==",
2942 + "dev": true,
2943 + "license": "MIT",
2944 + "dependencies": {
2945 + "cssstyle": "^4.2.1",
2946 + "data-urls": "^5.0.0",
2947 + "decimal.js": "^10.5.0",
2948 + "html-encoding-sniffer": "^4.0.0",
2949 + "http-proxy-agent": "^7.0.2",
2950 + "https-proxy-agent": "^7.0.6",
2951 + "is-potential-custom-element-name": "^1.0.1",
2952 + "nwsapi": "^2.2.16",
2953 + "parse5": "^7.2.1",
2954 + "rrweb-cssom": "^0.8.0",
2955 + "saxes": "^6.0.0",
2956 + "symbol-tree": "^3.2.4",
2957 + "tough-cookie": "^5.1.1",
2958 + "w3c-xmlserializer": "^5.0.0",
2959 + "webidl-conversions": "^7.0.0",
2960 + "whatwg-encoding": "^3.1.1",
2961 + "whatwg-mimetype": "^4.0.0",
2962 + "whatwg-url": "^14.1.1",
2963 + "ws": "^8.18.0",
2964 + "xml-name-validator": "^5.0.0"
2965 + },
2966 + "engines": {
2967 + "node": ">=18"
2968 + },
2969 + "peerDependencies": {
2970 + "canvas": "^3.0.0"
2971 + },
2972 + "peerDependenciesMeta": {
2973 + "canvas": {
2974 + "optional": true
2975 + }
2976 + }
2977 + },
2978 "node_modules/json-schema-traverse": {
2979 "version": "0.4.1",
2980 "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz",
@@ -2083,6 +3039,13 @@
3039 "url": "https://github.com/sponsors/sindresorhus"
3040 }
3041 },
3042 + "node_modules/lru-cache": {
3043 + "version": "10.4.3",
3044 + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.4.3.tgz",
3045 + "integrity": "sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==",
3046 + "dev": true,
3047 + "license": "ISC"
3048 + },
3049 "node_modules/miniflare": {
3050 "version": "5.20261019.2-beta",
3051 "resolved": "https://registry.npmjs.org/miniflare/-/miniflare-5.20261019.2-beta.tgz",
@@ -2124,6 +3087,25 @@
3087 "dev": true,
3088 "license": "MIT"
3089 },
3090 + "node_modules/nanoid": {
3091 + "version": "3.3.20",
3092 + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.20.tgz",
3093 + "integrity": "sha512-uKdg2G3GNCKQn9byYOpxbGqrT2fGO5KRt5J/8b3pok8rT6qxGWF6hxMyJiEYtAf+FVyYuD9hRaDqX5uPFYJ4ZQ==",
3094 + "dev": true,
3095 + "funding": [
3096 + {
3097 + "type": "github",
3098 + "url": "https://github.com/sponsors/ai"
3099 + }
3100 + ],
3101 + "license": "MIT",
3102 + "bin": {
3103 + "nanoid": "bin/nanoid.cjs"
3104 + },
3105 + "engines": {
3106 + "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1"
3107 + }
3108 + },
3109 "node_modules/natural-compare": {
3110 "version": "1.4.0",
3111 "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz",
@@ -2131,6 +3113,13 @@
3113 "dev": true,
3114 "license": "MIT"
3115 },
3116 + "node_modules/nwsapi": {
3117 + "version": "2.2.28",
3118 + "resolved": "https://registry.npmjs.org/nwsapi/-/nwsapi-2.2.28.tgz",
3119 + "integrity": "sha512-IlVB7OS7qrOsVYlpnFIkETjMwT9jwvmocJmmM+GZU/PAB3uGi9Ezd7vcWhWBUnSc0ya4ppmQITOyP1ez9gg8cg==",
3120 + "dev": true,
3121 + "license": "MIT"
3122 + },
3123 "node_modules/optionator": {
3124 "version": "0.9.4",
3125 "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.4.tgz",
@@ -2171,241 +3160,1129 @@
3160 "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==",
3161 "dev": true,
3162 "license": "MIT",
2174 - "dependencies": {
2175 - "p-limit": "^3.0.2"
2176 - },
3163 + "dependencies": {
3164 + "p-limit": "^3.0.2"
3165 + },
3166 + "engines": {
3167 + "node": ">=10"
3168 + },
3169 + "funding": {
3170 + "url": "https://github.com/sponsors/sindresorhus"
3171 + }
3172 + },
3173 + "node_modules/parse5": {
3174 + "version": "7.3.0",
3175 + "resolved": "https://registry.npmjs.org/parse5/-/parse5-7.3.0.tgz",
3176 + "integrity": "sha512-IInvU7fabl34qmi9gY8XOVxhYyMyuH2xUNpb2q8/Y+7552KlejkRvqvD19nMoUW/uQGGbqNpA6Tufu5FL5BZgw==",
3177 + "dev": true,
3178 + "license": "MIT",
3179 + "dependencies": {
3180 + "entities": "^6.0.0"
3181 + },
3182 + "funding": {
3183 + "url": "https://github.com/inikulin/parse5?sponsor=1"
3184 + }
3185 + },
3186 + "node_modules/path-exists": {
3187 + "version": "4.0.0",
3188 + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz",
3189 + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==",
3190 + "dev": true,
3191 + "license": "MIT",
3192 + "engines": {
3193 + "node": ">=8"
3194 + }
3195 + },
3196 + "node_modules/path-key": {
3197 + "version": "3.1.1",
3198 + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz",
3199 + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==",
3200 + "dev": true,
3201 + "license": "MIT",
3202 + "engines": {
3203 + "node": ">=8"
3204 + }
3205 + },
3206 + "node_modules/path-to-regexp": {
3207 + "version": "6.3.0",
3208 + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-6.3.0.tgz",
3209 + "integrity": "sha512-Yhpw4T9C6hPpgPeA28us07OJeqZ5EzQTkbfwuhsUg0c237RomFoETJgmp2sa3F/41gfLE6G5cqcYwznmeEeOlQ==",
3210 + "dev": true,
3211 + "license": "MIT"
3212 + },
3213 + "node_modules/pathe": {
3214 + "version": "2.0.3",
3215 + "resolved": "https://registry.npmjs.org/pathe/-/pathe-2.0.3.tgz",
3216 + "integrity": "sha512-WUjGcAqP1gQacoQe+OBJsFA7Ld4DyXuUIjZ5cc75cLHvJ7dtNsTugphxIADwspS+AraAUePCKrSVtPLFj/F88w==",
3217 + "dev": true,
3218 + "license": "MIT"
3219 + },
3220 + "node_modules/picocolors": {
3221 + "version": "1.1.1",
3222 + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz",
3223 + "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==",
3224 + "dev": true,
3225 + "license": "ISC"
3226 + },
3227 + "node_modules/picomatch": {
3228 + "version": "4.0.7",
3229 + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.7.tgz",
3230 + "integrity": "sha512-qcJu88Q2IWqJsDD529JKMdwGm/dvInW4HvQnRwiH9JtihJvzGOscDtHE3x1pBKeUOTysQ8kVmLnJ2kJu7yhcGA==",
3231 + "dev": true,
3232 + "license": "MIT",
3233 + "engines": {
3234 + "node": ">=12"
3235 + },
3236 + "funding": {
3237 + "url": "https://github.com/sponsors/jonschlinkert"
3238 + }
3239 + },
3240 + "node_modules/postcss": {
3241 + "version": "8.5.31",
3242 + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.31.tgz",
3243 + "integrity": "sha512-YUbWYCgErwnMAVkjUnYa+KlMBzGpHwiIt/DE7f0G33AuX2LH9UcTk6KgWxd3zRU+pN3u/C+Xl3EnMLM4Hea7Sg==",
3244 + "dev": true,
3245 + "funding": [
3246 + {
3247 + "type": "opencollective",
3248 + "url": "https://opencollective.com/postcss/"
3249 + },
3250 + {
3251 + "type": "tidelift",
3252 + "url": "https://tidelift.com/funding/github/npm/postcss"
3253 + },
3254 + {
3255 + "type": "github",
3256 + "url": "https://github.com/sponsors/ai"
3257 + }
3258 + ],
3259 + "license": "MIT",
3260 + "dependencies": {
3261 + "nanoid": "^3.3.20",
3262 + "picocolors": "^1.1.1",
3263 + "source-map-js": "^1.2.2"
3264 + },
3265 + "engines": {
3266 + "node": "^10 || ^12 || >=14"
3267 + }
3268 + },
3269 + "node_modules/prelude-ls": {
3270 + "version": "1.2.1",
3271 + "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz",
3272 + "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==",
3273 + "dev": true,
3274 + "license": "MIT",
3275 + "engines": {
3276 + "node": ">= 0.8.0"
3277 + }
3278 + },
3279 + "node_modules/prettier": {
3280 + "version": "3.6.2",
3281 + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.6.2.tgz",
3282 + "integrity": "sha512-I7AIg5boAr5R0FFtJ6rCfD+LFsWHp81dolrFD8S79U9tb8Az2nGrJncnMSnys+bpQJfRUzqs9hnA81OAA3hCuQ==",
3283 + "dev": true,
3284 + "license": "MIT",
3285 + "bin": {
3286 + "prettier": "bin/prettier.cjs"
3287 + },
3288 + "engines": {
3289 + "node": ">=14"
3290 + },
3291 + "funding": {
3292 + "url": "https://github.com/prettier/prettier?sponsor=1"
3293 + }
3294 + },
3295 + "node_modules/punycode": {
3296 + "version": "2.3.1",
3297 + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz",
3298 + "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==",
3299 + "dev": true,
3300 + "license": "MIT",
3301 + "engines": {
3302 + "node": ">=6"
3303 + }
3304 + },
3305 + "node_modules/qified": {
3306 + "version": "0.10.1",
3307 + "resolved": "https://registry.npmjs.org/qified/-/qified-0.10.1.tgz",
3308 + "integrity": "sha512-+Owyggi9IxT1ePKGafcI87ubSmxol6smwJ+RAHDQlx9+9cPwFWDiKFFCPuWhr9ignlGpZ9vDQLw67N4dcTVFEA==",
3309 + "dev": true,
3310 + "license": "MIT",
3311 + "dependencies": {
3312 + "hookified": "^2.1.1"
3313 + },
3314 + "engines": {
3315 + "node": ">=20"
3316 + }
3317 + },
3318 + "node_modules/qified/node_modules/hookified": {
3319 + "version": "2.2.0",
3320 + "resolved": "https://registry.npmjs.org/hookified/-/hookified-2.2.0.tgz",
3321 + "integrity": "sha512-p/LgFzRN5FeoD3DLS6bkUapeye6E4SI6yJs6KetENd18S+FBthqYq2amJUWpt5z0EQwwHemidjY5OqJGEKm5uA==",
3322 + "dev": true,
3323 + "license": "MIT"
3324 + },
3325 + "node_modules/react": {
3326 + "version": "19.2.0",
3327 + "resolved": "https://registry.npmjs.org/react/-/react-19.2.0.tgz",
3328 + "integrity": "sha512-tmbWg6W31tQLeB5cdIBOicJDJRR2KzXsV7uSK9iNfLWQ5bIZfxuPEHp7M8wiHyHnn0DD1i7w3Zmin0FtkrwoCQ==",
3329 + "license": "MIT",
3330 + "engines": {
3331 + "node": ">=0.10.0"
3332 + }
3333 + },
3334 + "node_modules/react-dom": {
3335 + "version": "19.2.0",
3336 + "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-19.2.0.tgz",
3337 + "integrity": "sha512-UlbRu4cAiGaIewkPyiRGJk0imDN2T3JjieT6spoL2UeSf5od4n5LB/mQ4ejmxhCFT1tYe8IvaFulzynWovsEFQ==",
3338 + "license": "MIT",
3339 + "dependencies": {
3340 + "scheduler": "^0.27.0"
3341 + },
3342 + "peerDependencies": {
3343 + "react": "^19.2.0"
3344 + }
3345 + },
3346 + "node_modules/rollup": {
3347 + "version": "4.65.0",
3348 + "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.65.0.tgz",
3349 + "integrity": "sha512-QVCvQUTGDN6JRwi3jVGCY3H4aTHvi9rX0LyoBMkGUvdh/Z6O51CzcLz85BWZaTCDGhl6ySGqYZs+xI1jmPqGcw==",
3350 + "dev": true,
3351 + "license": "MIT",
3352 + "dependencies": {
3353 + "@types/estree": "1.0.9"
3354 + },
3355 + "bin": {
3356 + "rollup": "dist/bin/rollup"
3357 + },
3358 + "engines": {
3359 + "node": ">=18.0.0",
3360 + "npm": ">=8.0.0"
3361 + },
3362 + "optionalDependencies": {
3363 + "@napi-rs/lzma-linux-x64-gnu": "1.5.1",
3364 + "@rollup/rollup-android-arm-eabi": "4.65.0",
3365 + "@rollup/rollup-android-arm64": "4.65.0",
3366 + "@rollup/rollup-darwin-arm64": "4.65.0",
3367 + "@rollup/rollup-darwin-x64": "4.65.0",
3368 + "@rollup/rollup-freebsd-arm64": "4.65.0",
3369 + "@rollup/rollup-freebsd-x64": "4.65.0",
3370 + "@rollup/rollup-linux-arm-gnueabihf": "4.65.0",
3371 + "@rollup/rollup-linux-arm-musleabihf": "4.65.0",
3372 + "@rollup/rollup-linux-arm64-gnu": "4.65.0",
3373 + "@rollup/rollup-linux-arm64-musl": "4.65.0",
3374 + "@rollup/rollup-linux-loong64-gnu": "4.65.0",
3375 + "@rollup/rollup-linux-loong64-musl": "4.65.0",
3376 + "@rollup/rollup-linux-ppc64-gnu": "4.65.0",
3377 + "@rollup/rollup-linux-ppc64-musl": "4.65.0",
3378 + "@rollup/rollup-linux-riscv64-gnu": "4.65.0",
3379 + "@rollup/rollup-linux-riscv64-musl": "4.65.0",
3380 + "@rollup/rollup-linux-s390x-gnu": "4.65.0",
3381 + "@rollup/rollup-linux-x64-gnu": "4.65.0",
3382 + "@rollup/rollup-linux-x64-musl": "4.65.0",
3383 + "@rollup/rollup-openbsd-x64": "4.65.0",
3384 + "@rollup/rollup-openharmony-arm64": "4.65.0",
3385 + "@rollup/rollup-win32-arm64-msvc": "4.65.0",
3386 + "@rollup/rollup-win32-ia32-msvc": "4.65.0",
3387 + "@rollup/rollup-win32-x64-gnu": "4.65.0",
3388 + "@rollup/rollup-win32-x64-msvc": "4.65.0",
3389 + "fsevents": "~2.3.2"
3390 + }
3391 + },
3392 + "node_modules/rrweb-cssom": {
3393 + "version": "0.8.0",
3394 + "resolved": "https://registry.npmjs.org/rrweb-cssom/-/rrweb-cssom-0.8.0.tgz",
3395 + "integrity": "sha512-guoltQEx+9aMf2gDZ0s62EcV8lsXR+0w8915TC3ITdn2YueuNjdAYh/levpU9nFaoChh9RUS5ZdQMrKfVEN9tw==",
3396 + "dev": true,
3397 + "license": "MIT"
3398 + },
3399 + "node_modules/safer-buffer": {
3400 + "version": "2.1.2",
3401 + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
3402 + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==",
3403 + "dev": true,
3404 + "license": "MIT"
3405 + },
3406 + "node_modules/saxes": {
3407 + "version": "6.0.0",
3408 + "resolved": "https://registry.npmjs.org/saxes/-/saxes-6.0.0.tgz",
3409 + "integrity": "sha512-xAg7SOnEhrm5zI3puOOKyy1OMcMlIJZYNJY7xLBwSze0UjhPLnWfj2GF2EpT0jmzaJKIWKHLsaSSajf35bcYnA==",
3410 + "dev": true,
3411 + "license": "ISC",
3412 + "dependencies": {
3413 + "xmlchars": "^2.2.0"
3414 + },
3415 + "engines": {
3416 + "node": ">=v12.22.7"
3417 + }
3418 + },
3419 + "node_modules/scheduler": {
3420 + "version": "0.27.0",
3421 + "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.27.0.tgz",
3422 + "integrity": "sha512-eNv+WrVbKu1f3vbYJT/xtiF5syA5HPIMtf9IgY/nKg0sWqzAUEvqY/xm7OcZc/qafLx/iO9FgOmeSAp4v5ti/Q==",
3423 + "license": "MIT"
3424 + },
3425 + "node_modules/semver": {
3426 + "version": "7.8.5",
3427 + "resolved": "https://registry.npmjs.org/semver/-/semver-7.8.5.tgz",
3428 + "integrity": "sha512-Y7/KDsb8LjooZpwaqGyulO6DQlksgCncchHGk+sZIY4SBvUocMBEFH5Ur1fI4dV+Jvl0w6cjvucaIi40puRioA==",
3429 + "dev": true,
3430 + "license": "ISC",
3431 + "bin": {
3432 + "semver": "bin/semver.js"
3433 + },
3434 + "engines": {
3435 + "node": ">=10"
3436 + }
3437 + },
3438 + "node_modules/sharp": {
3439 + "version": "0.35.5",
3440 + "resolved": "https://registry.npmjs.org/sharp/-/sharp-0.35.5.tgz",
3441 + "integrity": "sha512-Ywn4OnzGukp7CDMrp08RQ50YKmuwG47brZgIVPTvBaaAfQlRlygrRqSrxdCiL9M+LlzLBiJ68IR1QqvzHyjC7g==",
3442 + "dev": true,
3443 + "license": "Apache-2.0",
3444 + "dependencies": {
3445 + "@img/colour": "^1.1.0",
3446 + "detect-libc": "^2.1.2",
3447 + "semver": "^7.8.5"
3448 + },
3449 + "engines": {
3450 + "node": ">=20.9.0"
3451 + },
3452 + "funding": {
3453 + "url": "https://opencollective.com/libvips"
3454 + },
3455 + "optionalDependencies": {
3456 + "@img/sharp-darwin-arm64": "0.35.5",
3457 + "@img/sharp-darwin-x64": "0.35.5",
3458 + "@img/sharp-freebsd-wasm32": "0.35.5",
3459 + "@img/sharp-libvips-darwin-arm64": "1.3.4",
3460 + "@img/sharp-libvips-darwin-x64": "1.3.4",
3461 + "@img/sharp-libvips-linux-arm": "1.3.4",
3462 + "@img/sharp-libvips-linux-arm64": "1.3.4",
3463 + "@img/sharp-libvips-linux-ppc64": "1.3.4",
3464 + "@img/sharp-libvips-linux-riscv64": "1.3.4",
3465 + "@img/sharp-libvips-linux-s390x": "1.3.4",
3466 + "@img/sharp-libvips-linux-x64": "1.3.4",
3467 + "@img/sharp-libvips-linuxmusl-arm64": "1.3.4",
3468 + "@img/sharp-libvips-linuxmusl-x64": "1.3.4",
3469 + "@img/sharp-linux-arm": "0.35.5",
3470 + "@img/sharp-linux-arm64": "0.35.5",
3471 + "@img/sharp-linux-ppc64": "0.35.5",
3472 + "@img/sharp-linux-riscv64": "0.35.5",
3473 + "@img/sharp-linux-s390x": "0.35.5",
3474 + "@img/sharp-linux-x64": "0.35.5",
3475 + "@img/sharp-linuxmusl-arm64": "0.35.5",
3476 + "@img/sharp-linuxmusl-x64": "0.35.5",
3477 + "@img/sharp-webcontainers-wasm32": "0.35.5",
3478 + "@img/sharp-win32-arm64": "0.35.5",
3479 + "@img/sharp-win32-ia32": "0.35.5",
3480 + "@img/sharp-win32-x64": "0.35.5"
3481 + },
3482 + "peerDependenciesMeta": {
3483 + "@types/node": {
3484 + "optional": true
3485 + }
3486 + }
3487 + },
3488 + "node_modules/shebang-command": {
3489 + "version": "2.0.0",
3490 + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz",
3491 + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==",
3492 + "dev": true,
3493 + "license": "MIT",
3494 + "dependencies": {
3495 + "shebang-regex": "^3.0.0"
3496 + },
3497 + "engines": {
3498 + "node": ">=8"
3499 + }
3500 + },
3501 + "node_modules/shebang-regex": {
3502 + "version": "3.0.0",
3503 + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz",
3504 + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==",
3505 + "dev": true,
3506 + "license": "MIT",
3507 + "engines": {
3508 + "node": ">=8"
3509 + }
3510 + },
3511 + "node_modules/source-map-js": {
3512 + "version": "1.2.2",
3513 + "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.2.tgz",
3514 + "integrity": "sha512-KGj/8Y43x35aZVDtt+J4mK1hoLGHULMYfSkODJNQjNDC3oW1PqPoxMwo0pLUsWM/UEGzON/NxeHywEfNXNP3Vw==",
3515 + "dev": true,
3516 + "license": "BSD-3-Clause",
3517 + "engines": {
3518 + "node": ">=0.10.0"
3519 + }
3520 + },
3521 + "node_modules/style-mod": {
3522 + "version": "4.1.4",
3523 + "resolved": "https://registry.npmjs.org/style-mod/-/style-mod-4.1.4.tgz",
3524 + "integrity": "sha512-XXWIQt633/EpAFx8aZDOTjBzrCaGmhvEQlQo6MVPfa2OzO2cWo+4hV9h+6UkHYlXGfy+ODXKUdP7Pthmcu5ATw==",
3525 + "license": "MIT"
3526 + },
3527 + "node_modules/symbol-tree": {
3528 + "version": "3.2.4",
3529 + "resolved": "https://registry.npmjs.org/symbol-tree/-/symbol-tree-3.2.4.tgz",
3530 + "integrity": "sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw==",
3531 + "dev": true,
3532 + "license": "MIT"
3533 + },
3534 + "node_modules/tinyglobby": {
3535 + "version": "0.2.17",
3536 + "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.17.tgz",
3537 + "integrity": "sha512-wXR/dYpcqKmfWpEdZjiKJOwCNFndD0DMnrW/cYjVGttEkBfVgcLFHoNrlj47mjOVic9yyNu65alsgF4NQyTa2g==",
3538 + "dev": true,
3539 + "license": "MIT",
3540 + "dependencies": {
3541 + "fdir": "^6.5.0",
3542 + "picomatch": "^4.0.4"
3543 + },
3544 + "engines": {
3545 + "node": ">=12.0.0"
3546 + },
3547 + "funding": {
3548 + "url": "https://github.com/sponsors/SuperchupuDev"
3549 + }
3550 + },
3551 + "node_modules/tldts": {
3552 + "version": "6.1.86",
3553 + "resolved": "https://registry.npmjs.org/tldts/-/tldts-6.1.86.tgz",
3554 + "integrity": "sha512-WMi/OQ2axVTf/ykqCQgXiIct+mSQDFdH2fkwhPwgEwvJ1kSzZRiinb0zF2Xb8u4+OqPChmyI6MEu4EezNJz+FQ==",
3555 + "dev": true,
3556 + "license": "MIT",
3557 + "dependencies": {
3558 + "tldts-core": "^6.1.86"
3559 + },
3560 + "bin": {
3561 + "tldts": "bin/cli.js"
3562 + }
3563 + },
3564 + "node_modules/tldts-core": {
3565 + "version": "6.1.86",
3566 + "resolved": "https://registry.npmjs.org/tldts-core/-/tldts-core-6.1.86.tgz",
3567 + "integrity": "sha512-Je6p7pkk+KMzMv2XXKmAE3McmolOQFdxkKw0R8EYNr7sELW46JqnNeTX8ybPiQgvg1ymCoF8LXs5fzFaZvJPTA==",
3568 + "dev": true,
3569 + "license": "MIT"
3570 + },
3571 + "node_modules/tough-cookie": {
3572 + "version": "5.1.2",
3573 + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-5.1.2.tgz",
3574 + "integrity": "sha512-FVDYdxtnj0G6Qm/DhNPSb8Ju59ULcup3tuJxkFb5K8Bv2pUXILbf0xZWU8PX8Ov19OXljbUyveOFwRMwkXzO+A==",
3575 + "dev": true,
3576 + "license": "BSD-3-Clause",
3577 + "dependencies": {
3578 + "tldts": "^6.1.32"
3579 + },
3580 + "engines": {
3581 + "node": ">=16"
3582 + }
3583 + },
3584 + "node_modules/tr46": {
3585 + "version": "5.1.1",
3586 + "resolved": "https://registry.npmjs.org/tr46/-/tr46-5.1.1.tgz",
3587 + "integrity": "sha512-hdF5ZgjTqgAntKkklYw0R03MG2x/bSzTtkxmIRw/sTNV8YXsCJ1tfLAX23lhxhHJlEf3CRCOCGGWw3vI3GaSPw==",
3588 + "dev": true,
3589 + "license": "MIT",
3590 + "dependencies": {
3591 + "punycode": "^2.3.1"
3592 + },
3593 + "engines": {
3594 + "node": ">=18"
3595 + }
3596 + },
3597 + "node_modules/tslib": {
3598 + "version": "2.8.1",
3599 + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz",
3600 + "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==",
3601 + "dev": true,
3602 + "license": "0BSD",
3603 + "optional": true
3604 + },
3605 + "node_modules/type-check": {
3606 + "version": "0.4.0",
3607 + "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz",
3608 + "integrity": "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==",
3609 + "dev": true,
3610 + "license": "MIT",
3611 + "dependencies": {
3612 + "prelude-ls": "^1.2.1"
3613 + },
3614 + "engines": {
3615 + "node": ">= 0.8.0"
3616 + }
3617 + },
3618 + "node_modules/typescript": {
3619 + "version": "5.9.3",
3620 + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz",
3621 + "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==",
3622 + "dev": true,
3623 + "license": "Apache-2.0",
3624 + "bin": {
3625 + "tsc": "bin/tsc",
3626 + "tsserver": "bin/tsserver"
3627 + },
3628 + "engines": {
3629 + "node": ">=14.17"
3630 + }
3631 + },
3632 + "node_modules/undici": {
3633 + "version": "7.29.1",
3634 + "resolved": "https://registry.npmjs.org/undici/-/undici-7.29.1.tgz",
3635 + "integrity": "sha512-RYONW2MeafgYlkVOKYKkA/Ag7BmXqgIWCa8t1m0JcxrQg9pI9lEqRhAOruOBCbAohOa/gkCF+iPi9hrgvTzu6Q==",
3636 + "dev": true,
3637 + "license": "MIT",
3638 + "engines": {
3639 + "node": ">=20.18.1"
3640 + }
3641 + },
3642 + "node_modules/unenv": {
3643 + "version": "2.0.0-rc.24",
3644 + "resolved": "https://registry.npmjs.org/unenv/-/unenv-2.0.0-rc.24.tgz",
3645 + "integrity": "sha512-i7qRCmY42zmCwnYlh9H2SvLEypEFGye5iRmEMKjcGi7zk9UquigRjFtTLz0TYqr0ZGLZhaMHl/foy1bZR+Cwlw==",
3646 + "dev": true,
3647 + "license": "MIT",
3648 + "dependencies": {
3649 + "pathe": "^2.0.3"
3650 + }
3651 + },
3652 + "node_modules/uri-js": {
3653 + "version": "4.4.1",
3654 + "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz",
3655 + "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==",
3656 + "dev": true,
3657 + "license": "BSD-2-Clause",
3658 + "dependencies": {
3659 + "punycode": "^2.1.0"
3660 + }
3661 + },
3662 + "node_modules/vite": {
3663 + "version": "7.2.2",
3664 + "resolved": "https://registry.npmjs.org/vite/-/vite-7.2.2.tgz",
3665 + "integrity": "sha512-BxAKBWmIbrDgrokdGZH1IgkIk/5mMHDreLDmCJ0qpyJaAteP8NvMhkwr/ZCQNqNH97bw/dANTE9PDzqwJghfMQ==",
3666 + "dev": true,
3667 + "license": "MIT",
3668 + "dependencies": {
3669 + "esbuild": "^0.25.0",
3670 + "fdir": "^6.5.0",
3671 + "picomatch": "^4.0.3",
3672 + "postcss": "^8.5.6",
3673 + "rollup": "^4.43.0",
3674 + "tinyglobby": "^0.2.15"
3675 + },
3676 + "bin": {
3677 + "vite": "bin/vite.js"
3678 + },
3679 + "engines": {
3680 + "node": "^20.19.0 || >=22.12.0"
3681 + },
3682 + "funding": {
3683 + "url": "https://github.com/vitejs/vite?sponsor=1"
3684 + },
3685 + "optionalDependencies": {
3686 + "fsevents": "~2.3.3"
3687 + },
3688 + "peerDependencies": {
3689 + "@types/node": "^20.19.0 || >=22.12.0",
3690 + "jiti": ">=1.21.0",
3691 + "less": "^4.0.0",
3692 + "lightningcss": "^1.21.0",
3693 + "sass": "^1.70.0",
3694 + "sass-embedded": "^1.70.0",
3695 + "stylus": ">=0.54.8",
3696 + "sugarss": "^5.0.0",
3697 + "terser": "^5.16.0",
3698 + "tsx": "^4.8.1",
3699 + "yaml": "^2.4.2"
3700 + },
3701 + "peerDependenciesMeta": {
3702 + "@types/node": {
3703 + "optional": true
3704 + },
3705 + "jiti": {
3706 + "optional": true
3707 + },
3708 + "less": {
3709 + "optional": true
3710 + },
3711 + "lightningcss": {
3712 + "optional": true
3713 + },
3714 + "sass": {
3715 + "optional": true
3716 + },
3717 + "sass-embedded": {
3718 + "optional": true
3719 + },
3720 + "stylus": {
3721 + "optional": true
3722 + },
3723 + "sugarss": {
3724 + "optional": true
3725 + },
3726 + "terser": {
3727 + "optional": true
3728 + },
3729 + "tsx": {
3730 + "optional": true
3731 + },
3732 + "yaml": {
3733 + "optional": true
3734 + }
3735 + }
3736 + },
3737 + "node_modules/vite/node_modules/@esbuild/aix-ppc64": {
3738 + "version": "0.25.12",
3739 + "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.25.12.tgz",
3740 + "integrity": "sha512-Hhmwd6CInZ3dwpuGTF8fJG6yoWmsToE+vYgD4nytZVxcu1ulHpUQRAB1UJ8+N1Am3Mz4+xOByoQoSZf4D+CpkA==",
3741 + "cpu": [
3742 + "ppc64"
3743 + ],
3744 + "dev": true,
3745 + "license": "MIT",
3746 + "optional": true,
3747 + "os": [
3748 + "aix"
3749 + ],
3750 + "engines": {
3751 + "node": ">=18"
3752 + }
3753 + },
3754 + "node_modules/vite/node_modules/@esbuild/android-arm": {
3755 + "version": "0.25.12",
3756 + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.25.12.tgz",
3757 + "integrity": "sha512-VJ+sKvNA/GE7Ccacc9Cha7bpS8nyzVv0jdVgwNDaR4gDMC/2TTRc33Ip8qrNYUcpkOHUT5OZ0bUcNNVZQ9RLlg==",
3758 + "cpu": [
3759 + "arm"
3760 + ],
3761 + "dev": true,
3762 + "license": "MIT",
3763 + "optional": true,
3764 + "os": [
3765 + "android"
3766 + ],
3767 + "engines": {
3768 + "node": ">=18"
3769 + }
3770 + },
3771 + "node_modules/vite/node_modules/@esbuild/android-arm64": {
3772 + "version": "0.25.12",
3773 + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.25.12.tgz",
3774 + "integrity": "sha512-6AAmLG7zwD1Z159jCKPvAxZd4y/VTO0VkprYy+3N2FtJ8+BQWFXU+OxARIwA46c5tdD9SsKGZ/1ocqBS/gAKHg==",
3775 + "cpu": [
3776 + "arm64"
3777 + ],
3778 + "dev": true,
3779 + "license": "MIT",
3780 + "optional": true,
3781 + "os": [
3782 + "android"
3783 + ],
3784 + "engines": {
3785 + "node": ">=18"
3786 + }
3787 + },
3788 + "node_modules/vite/node_modules/@esbuild/android-x64": {
3789 + "version": "0.25.12",
3790 + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.25.12.tgz",
3791 + "integrity": "sha512-5jbb+2hhDHx5phYR2By8GTWEzn6I9UqR11Kwf22iKbNpYrsmRB18aX/9ivc5cabcUiAT/wM+YIZ6SG9QO6a8kg==",
3792 + "cpu": [
3793 + "x64"
3794 + ],
3795 + "dev": true,
3796 + "license": "MIT",
3797 + "optional": true,
3798 + "os": [
3799 + "android"
3800 + ],
3801 + "engines": {
3802 + "node": ">=18"
3803 + }
3804 + },
3805 + "node_modules/vite/node_modules/@esbuild/darwin-arm64": {
3806 + "version": "0.25.12",
3807 + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.25.12.tgz",
3808 + "integrity": "sha512-N3zl+lxHCifgIlcMUP5016ESkeQjLj/959RxxNYIthIg+CQHInujFuXeWbWMgnTo4cp5XVHqFPmpyu9J65C1Yg==",
3809 + "cpu": [
3810 + "arm64"
3811 + ],
3812 + "dev": true,
3813 + "license": "MIT",
3814 + "optional": true,
3815 + "os": [
3816 + "darwin"
3817 + ],
3818 + "engines": {
3819 + "node": ">=18"
3820 + }
3821 + },
3822 + "node_modules/vite/node_modules/@esbuild/darwin-x64": {
3823 + "version": "0.25.12",
3824 + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.25.12.tgz",
3825 + "integrity": "sha512-HQ9ka4Kx21qHXwtlTUVbKJOAnmG1ipXhdWTmNXiPzPfWKpXqASVcWdnf2bnL73wgjNrFXAa3yYvBSd9pzfEIpA==",
3826 + "cpu": [
3827 + "x64"
3828 + ],
3829 + "dev": true,
3830 + "license": "MIT",
3831 + "optional": true,
3832 + "os": [
3833 + "darwin"
3834 + ],
3835 + "engines": {
3836 + "node": ">=18"
3837 + }
3838 + },
3839 + "node_modules/vite/node_modules/@esbuild/freebsd-arm64": {
3840 + "version": "0.25.12",
3841 + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.25.12.tgz",
3842 + "integrity": "sha512-gA0Bx759+7Jve03K1S0vkOu5Lg/85dou3EseOGUes8flVOGxbhDDh/iZaoek11Y8mtyKPGF3vP8XhnkDEAmzeg==",
3843 + "cpu": [
3844 + "arm64"
3845 + ],
3846 + "dev": true,
3847 + "license": "MIT",
3848 + "optional": true,
3849 + "os": [
3850 + "freebsd"
3851 + ],
3852 + "engines": {
3853 + "node": ">=18"
3854 + }
3855 + },
3856 + "node_modules/vite/node_modules/@esbuild/freebsd-x64": {
3857 + "version": "0.25.12",
3858 + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.25.12.tgz",
3859 + "integrity": "sha512-TGbO26Yw2xsHzxtbVFGEXBFH0FRAP7gtcPE7P5yP7wGy7cXK2oO7RyOhL5NLiqTlBh47XhmIUXuGciXEqYFfBQ==",
3860 + "cpu": [
3861 + "x64"
3862 + ],
3863 + "dev": true,
3864 + "license": "MIT",
3865 + "optional": true,
3866 + "os": [
3867 + "freebsd"
3868 + ],
3869 + "engines": {
3870 + "node": ">=18"
3871 + }
3872 + },
3873 + "node_modules/vite/node_modules/@esbuild/linux-arm": {
3874 + "version": "0.25.12",
3875 + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.25.12.tgz",
3876 + "integrity": "sha512-lPDGyC1JPDou8kGcywY0YILzWlhhnRjdof3UlcoqYmS9El818LLfJJc3PXXgZHrHCAKs/Z2SeZtDJr5MrkxtOw==",
3877 + "cpu": [
3878 + "arm"
3879 + ],
3880 + "dev": true,
3881 + "license": "MIT",
3882 + "optional": true,
3883 + "os": [
3884 + "linux"
3885 + ],
3886 + "engines": {
3887 + "node": ">=18"
3888 + }
3889 + },
3890 + "node_modules/vite/node_modules/@esbuild/linux-arm64": {
3891 + "version": "0.25.12",
3892 + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.25.12.tgz",
3893 + "integrity": "sha512-8bwX7a8FghIgrupcxb4aUmYDLp8pX06rGh5HqDT7bB+8Rdells6mHvrFHHW2JAOPZUbnjUpKTLg6ECyzvas2AQ==",
3894 + "cpu": [
3895 + "arm64"
3896 + ],
3897 + "dev": true,
3898 + "license": "MIT",
3899 + "optional": true,
3900 + "os": [
3901 + "linux"
3902 + ],
3903 + "engines": {
3904 + "node": ">=18"
3905 + }
3906 + },
3907 + "node_modules/vite/node_modules/@esbuild/linux-ia32": {
3908 + "version": "0.25.12",
3909 + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.25.12.tgz",
3910 + "integrity": "sha512-0y9KrdVnbMM2/vG8KfU0byhUN+EFCny9+8g202gYqSSVMonbsCfLjUO+rCci7pM0WBEtz+oK/PIwHkzxkyharA==",
3911 + "cpu": [
3912 + "ia32"
3913 + ],
3914 + "dev": true,
3915 + "license": "MIT",
3916 + "optional": true,
3917 + "os": [
3918 + "linux"
3919 + ],
3920 + "engines": {
3921 + "node": ">=18"
3922 + }
3923 + },
3924 + "node_modules/vite/node_modules/@esbuild/linux-loong64": {
3925 + "version": "0.25.12",
3926 + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.25.12.tgz",
3927 + "integrity": "sha512-h///Lr5a9rib/v1GGqXVGzjL4TMvVTv+s1DPoxQdz7l/AYv6LDSxdIwzxkrPW438oUXiDtwM10o9PmwS/6Z0Ng==",
3928 + "cpu": [
3929 + "loong64"
3930 + ],
3931 + "dev": true,
3932 + "license": "MIT",
3933 + "optional": true,
3934 + "os": [
3935 + "linux"
3936 + ],
3937 + "engines": {
3938 + "node": ">=18"
3939 + }
3940 + },
3941 + "node_modules/vite/node_modules/@esbuild/linux-mips64el": {
3942 + "version": "0.25.12",
3943 + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.25.12.tgz",
3944 + "integrity": "sha512-iyRrM1Pzy9GFMDLsXn1iHUm18nhKnNMWscjmp4+hpafcZjrr2WbT//d20xaGljXDBYHqRcl8HnxbX6uaA/eGVw==",
3945 + "cpu": [
3946 + "mips64el"
3947 + ],
3948 + "dev": true,
3949 + "license": "MIT",
3950 + "optional": true,
3951 + "os": [
3952 + "linux"
3953 + ],
3954 + "engines": {
3955 + "node": ">=18"
3956 + }
3957 + },
3958 + "node_modules/vite/node_modules/@esbuild/linux-ppc64": {
3959 + "version": "0.25.12",
3960 + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.25.12.tgz",
3961 + "integrity": "sha512-9meM/lRXxMi5PSUqEXRCtVjEZBGwB7P/D4yT8UG/mwIdze2aV4Vo6U5gD3+RsoHXKkHCfSxZKzmDssVlRj1QQA==",
3962 + "cpu": [
3963 + "ppc64"
3964 + ],
3965 + "dev": true,
3966 + "license": "MIT",
3967 + "optional": true,
3968 + "os": [
3969 + "linux"
3970 + ],
3971 + "engines": {
3972 + "node": ">=18"
3973 + }
3974 + },
3975 + "node_modules/vite/node_modules/@esbuild/linux-riscv64": {
3976 + "version": "0.25.12",
3977 + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.25.12.tgz",
3978 + "integrity": "sha512-Zr7KR4hgKUpWAwb1f3o5ygT04MzqVrGEGXGLnj15YQDJErYu/BGg+wmFlIDOdJp0PmB0lLvxFIOXZgFRrdjR0w==",
3979 + "cpu": [
3980 + "riscv64"
3981 + ],
3982 + "dev": true,
3983 + "license": "MIT",
3984 + "optional": true,
3985 + "os": [
3986 + "linux"
3987 + ],
3988 + "engines": {
3989 + "node": ">=18"
3990 + }
3991 + },
3992 + "node_modules/vite/node_modules/@esbuild/linux-s390x": {
3993 + "version": "0.25.12",
3994 + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.25.12.tgz",
3995 + "integrity": "sha512-MsKncOcgTNvdtiISc/jZs/Zf8d0cl/t3gYWX8J9ubBnVOwlk65UIEEvgBORTiljloIWnBzLs4qhzPkJcitIzIg==",
3996 + "cpu": [
3997 + "s390x"
3998 + ],
3999 + "dev": true,
4000 + "license": "MIT",
4001 + "optional": true,
4002 + "os": [
4003 + "linux"
4004 + ],
4005 + "engines": {
4006 + "node": ">=18"
4007 + }
4008 + },
4009 + "node_modules/vite/node_modules/@esbuild/linux-x64": {
4010 + "version": "0.25.12",
4011 + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.25.12.tgz",
4012 + "integrity": "sha512-uqZMTLr/zR/ed4jIGnwSLkaHmPjOjJvnm6TVVitAa08SLS9Z0VM8wIRx7gWbJB5/J54YuIMInDquWyYvQLZkgw==",
4013 + "cpu": [
4014 + "x64"
4015 + ],
4016 + "dev": true,
4017 + "license": "MIT",
4018 + "optional": true,
4019 + "os": [
4020 + "linux"
4021 + ],
4022 + "engines": {
4023 + "node": ">=18"
4024 + }
4025 + },
4026 + "node_modules/vite/node_modules/@esbuild/netbsd-arm64": {
4027 + "version": "0.25.12",
4028 + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.25.12.tgz",
4029 + "integrity": "sha512-xXwcTq4GhRM7J9A8Gv5boanHhRa/Q9KLVmcyXHCTaM4wKfIpWkdXiMog/KsnxzJ0A1+nD+zoecuzqPmCRyBGjg==",
4030 + "cpu": [
4031 + "arm64"
4032 + ],
4033 + "dev": true,
4034 + "license": "MIT",
4035 + "optional": true,
4036 + "os": [
4037 + "netbsd"
4038 + ],
4039 + "engines": {
4040 + "node": ">=18"
4041 + }
4042 + },
4043 + "node_modules/vite/node_modules/@esbuild/netbsd-x64": {
4044 + "version": "0.25.12",
4045 + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.25.12.tgz",
4046 + "integrity": "sha512-Ld5pTlzPy3YwGec4OuHh1aCVCRvOXdH8DgRjfDy/oumVovmuSzWfnSJg+VtakB9Cm0gxNO9BzWkj6mtO1FMXkQ==",
4047 + "cpu": [
4048 + "x64"
4049 + ],
4050 + "dev": true,
4051 + "license": "MIT",
4052 + "optional": true,
4053 + "os": [
4054 + "netbsd"
4055 + ],
4056 "engines": {
2178 - "node": ">=10"
2179 - },
2180 - "funding": {
2181 - "url": "https://github.com/sponsors/sindresorhus"
4057 + "node": ">=18"
4058 }
4059 },
2184 - "node_modules/path-exists": {
2185 - "version": "4.0.0",
2186 - "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz",
2187 - "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==",
4060 + "node_modules/vite/node_modules/@esbuild/openbsd-arm64": {
4061 + "version": "0.25.12",
4062 + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.25.12.tgz",
4063 + "integrity": "sha512-fF96T6KsBo/pkQI950FARU9apGNTSlZGsv1jZBAlcLL1MLjLNIWPBkj5NlSz8aAzYKg+eNqknrUJ24QBybeR5A==",
4064 + "cpu": [
4065 + "arm64"
4066 + ],
4067 "dev": true,
4068 "license": "MIT",
4069 + "optional": true,
4070 + "os": [
4071 + "openbsd"
4072 + ],
4073 "engines": {
2191 - "node": ">=8"
4074 + "node": ">=18"
4075 }
4076 },
2194 - "node_modules/path-key": {
2195 - "version": "3.1.1",
2196 - "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz",
2197 - "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==",
4077 + "node_modules/vite/node_modules/@esbuild/openbsd-x64": {
4078 + "version": "0.25.12",
4079 + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.25.12.tgz",
4080 + "integrity": "sha512-MZyXUkZHjQxUvzK7rN8DJ3SRmrVrke8ZyRusHlP+kuwqTcfWLyqMOE3sScPPyeIXN/mDJIfGXvcMqCgYKekoQw==",
4081 + "cpu": [
4082 + "x64"
4083 + ],
4084 "dev": true,
4085 "license": "MIT",
4086 + "optional": true,
4087 + "os": [
4088 + "openbsd"
4089 + ],
4090 "engines": {
2201 - "node": ">=8"
4091 + "node": ">=18"
4092 }
4093 },
2204 - "node_modules/path-to-regexp": {
2205 - "version": "6.3.0",
2206 - "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-6.3.0.tgz",
2207 - "integrity": "sha512-Yhpw4T9C6hPpgPeA28us07OJeqZ5EzQTkbfwuhsUg0c237RomFoETJgmp2sa3F/41gfLE6G5cqcYwznmeEeOlQ==",
2208 - "dev": true,
2209 - "license": "MIT"
2210 - },
2211 - "node_modules/pathe": {
2212 - "version": "2.0.3",
2213 - "resolved": "https://registry.npmjs.org/pathe/-/pathe-2.0.3.tgz",
2214 - "integrity": "sha512-WUjGcAqP1gQacoQe+OBJsFA7Ld4DyXuUIjZ5cc75cLHvJ7dtNsTugphxIADwspS+AraAUePCKrSVtPLFj/F88w==",
2215 - "dev": true,
2216 - "license": "MIT"
2217 - },
2218 - "node_modules/prelude-ls": {
2219 - "version": "1.2.1",
2220 - "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz",
2221 - "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==",
4094 + "node_modules/vite/node_modules/@esbuild/openharmony-arm64": {
4095 + "version": "0.25.12",
4096 + "resolved": "https://registry.npmjs.org/@esbuild/openharmony-arm64/-/openharmony-arm64-0.25.12.tgz",
4097 + "integrity": "sha512-rm0YWsqUSRrjncSXGA7Zv78Nbnw4XL6/dzr20cyrQf7ZmRcsovpcRBdhD43Nuk3y7XIoW2OxMVvwuRvk9XdASg==",
4098 + "cpu": [
4099 + "arm64"
4100 + ],
4101 "dev": true,
4102 "license": "MIT",
4103 + "optional": true,
4104 + "os": [
4105 + "openharmony"
4106 + ],
4107 "engines": {
2225 - "node": ">= 0.8.0"
4108 + "node": ">=18"
4109 }
4110 },
2228 - "node_modules/prettier": {
2229 - "version": "3.6.2",
2230 - "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.6.2.tgz",
2231 - "integrity": "sha512-I7AIg5boAr5R0FFtJ6rCfD+LFsWHp81dolrFD8S79U9tb8Az2nGrJncnMSnys+bpQJfRUzqs9hnA81OAA3hCuQ==",
4111 + "node_modules/vite/node_modules/@esbuild/sunos-x64": {
4112 + "version": "0.25.12",
4113 + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.25.12.tgz",
4114 + "integrity": "sha512-3wGSCDyuTHQUzt0nV7bocDy72r2lI33QL3gkDNGkod22EsYl04sMf0qLb8luNKTOmgF/eDEDP5BFNwoBKH441w==",
4115 + "cpu": [
4116 + "x64"
4117 + ],
4118 "dev": true,
4119 "license": "MIT",
2234 - "bin": {
2235 - "prettier": "bin/prettier.cjs"
2236 - },
4120 + "optional": true,
4121 + "os": [
4122 + "sunos"
4123 + ],
4124 "engines": {
2238 - "node": ">=14"
2239 - },
2240 - "funding": {
2241 - "url": "https://github.com/prettier/prettier?sponsor=1"
4125 + "node": ">=18"
4126 }
4127 },
2244 - "node_modules/punycode": {
2245 - "version": "2.3.1",
2246 - "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz",
2247 - "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==",
4128 + "node_modules/vite/node_modules/@esbuild/win32-arm64": {
4129 + "version": "0.25.12",
4130 + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.25.12.tgz",
4131 + "integrity": "sha512-rMmLrur64A7+DKlnSuwqUdRKyd3UE7oPJZmnljqEptesKM8wx9J8gx5u0+9Pq0fQQW8vqeKebwNXdfOyP+8Bsg==",
4132 + "cpu": [
4133 + "arm64"
4134 + ],
4135 "dev": true,
4136 "license": "MIT",
4137 + "optional": true,
4138 + "os": [
4139 + "win32"
4140 + ],
4141 "engines": {
2251 - "node": ">=6"
4142 + "node": ">=18"
4143 }
4144 },
2254 - "node_modules/qified": {
2255 - "version": "0.10.1",
2256 - "resolved": "https://registry.npmjs.org/qified/-/qified-0.10.1.tgz",
2257 - "integrity": "sha512-+Owyggi9IxT1ePKGafcI87ubSmxol6smwJ+RAHDQlx9+9cPwFWDiKFFCPuWhr9ignlGpZ9vDQLw67N4dcTVFEA==",
4145 + "node_modules/vite/node_modules/@esbuild/win32-ia32": {
4146 + "version": "0.25.12",
4147 + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.25.12.tgz",
4148 + "integrity": "sha512-HkqnmmBoCbCwxUKKNPBixiWDGCpQGVsrQfJoVGYLPT41XWF8lHuE5N6WhVia2n4o5QK5M4tYr21827fNhi4byQ==",
4149 + "cpu": [
4150 + "ia32"
4151 + ],
4152 "dev": true,
4153 "license": "MIT",
2260 - "dependencies": {
2261 - "hookified": "^2.1.1"
2262 - },
4154 + "optional": true,
4155 + "os": [
4156 + "win32"
4157 + ],
4158 "engines": {
2264 - "node": ">=20"
4159 + "node": ">=18"
4160 }
4161 },
2267 - "node_modules/qified/node_modules/hookified": {
2268 - "version": "2.2.0",
2269 - "resolved": "https://registry.npmjs.org/hookified/-/hookified-2.2.0.tgz",
2270 - "integrity": "sha512-p/LgFzRN5FeoD3DLS6bkUapeye6E4SI6yJs6KetENd18S+FBthqYq2amJUWpt5z0EQwwHemidjY5OqJGEKm5uA==",
2271 - "dev": true,
2272 - "license": "MIT"
2273 - },
2274 - "node_modules/semver": {
2275 - "version": "7.8.5",
2276 - "resolved": "https://registry.npmjs.org/semver/-/semver-7.8.5.tgz",
2277 - "integrity": "sha512-Y7/KDsb8LjooZpwaqGyulO6DQlksgCncchHGk+sZIY4SBvUocMBEFH5Ur1fI4dV+Jvl0w6cjvucaIi40puRioA==",
4162 + "node_modules/vite/node_modules/@esbuild/win32-x64": {
4163 + "version": "0.25.12",
4164 + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.25.12.tgz",
4165 + "integrity": "sha512-alJC0uCZpTFrSL0CCDjcgleBXPnCrEAhTBILpeAp7M/OFgoqtAetfBzX0xM00MUsVVPpVjlPuMbREqnZCXaTnA==",
4166 + "cpu": [
4167 + "x64"
4168 + ],
4169 "dev": true,
2279 - "license": "ISC",
2280 - "bin": {
2281 - "semver": "bin/semver.js"
2282 - },
4170 + "license": "MIT",
4171 + "optional": true,
4172 + "os": [
4173 + "win32"
4174 + ],
4175 "engines": {
2284 - "node": ">=10"
4176 + "node": ">=18"
4177 }
4178 },
2287 - "node_modules/sharp": {
2288 - "version": "0.35.5",
2289 - "resolved": "https://registry.npmjs.org/sharp/-/sharp-0.35.5.tgz",
2290 - "integrity": "sha512-Ywn4OnzGukp7CDMrp08RQ50YKmuwG47brZgIVPTvBaaAfQlRlygrRqSrxdCiL9M+LlzLBiJ68IR1QqvzHyjC7g==",
4179 + "node_modules/vite/node_modules/esbuild": {
4180 + "version": "0.25.12",
4181 + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.25.12.tgz",
4182 + "integrity": "sha512-bbPBYYrtZbkt6Os6FiTLCTFxvq4tt3JKall1vRwshA3fdVztsLAatFaZobhkBC8/BrPetoa0oksYoKXoG4ryJg==",
4183 "dev": true,
2292 - "license": "Apache-2.0",
2293 - "dependencies": {
2294 - "@img/colour": "^1.1.0",
2295 - "detect-libc": "^2.1.2",
2296 - "semver": "^7.8.5"
4184 + "hasInstallScript": true,
4185 + "license": "MIT",
4186 + "bin": {
4187 + "esbuild": "bin/esbuild"
4188 },
4189 "engines": {
2299 - "node": ">=20.9.0"
2300 - },
2301 - "funding": {
2302 - "url": "https://opencollective.com/libvips"
4190 + "node": ">=18"
4191 },
4192 "optionalDependencies": {
2305 - "@img/sharp-darwin-arm64": "0.35.5",
2306 - "@img/sharp-darwin-x64": "0.35.5",
2307 - "@img/sharp-freebsd-wasm32": "0.35.5",
2308 - "@img/sharp-libvips-darwin-arm64": "1.3.4",
2309 - "@img/sharp-libvips-darwin-x64": "1.3.4",
2310 - "@img/sharp-libvips-linux-arm": "1.3.4",
2311 - "@img/sharp-libvips-linux-arm64": "1.3.4",
2312 - "@img/sharp-libvips-linux-ppc64": "1.3.4",
2313 - "@img/sharp-libvips-linux-riscv64": "1.3.4",
2314 - "@img/sharp-libvips-linux-s390x": "1.3.4",
2315 - "@img/sharp-libvips-linux-x64": "1.3.4",
2316 - "@img/sharp-libvips-linuxmusl-arm64": "1.3.4",
2317 - "@img/sharp-libvips-linuxmusl-x64": "1.3.4",
2318 - "@img/sharp-linux-arm": "0.35.5",
2319 - "@img/sharp-linux-arm64": "0.35.5",
2320 - "@img/sharp-linux-ppc64": "0.35.5",
2321 - "@img/sharp-linux-riscv64": "0.35.5",
2322 - "@img/sharp-linux-s390x": "0.35.5",
2323 - "@img/sharp-linux-x64": "0.35.5",
2324 - "@img/sharp-linuxmusl-arm64": "0.35.5",
2325 - "@img/sharp-linuxmusl-x64": "0.35.5",
2326 - "@img/sharp-webcontainers-wasm32": "0.35.5",
2327 - "@img/sharp-win32-arm64": "0.35.5",
2328 - "@img/sharp-win32-ia32": "0.35.5",
2329 - "@img/sharp-win32-x64": "0.35.5"
2330 - },
2331 - "peerDependenciesMeta": {
2332 - "@types/node": {
2333 - "optional": true
2334 - }
2335 - }
4193 + "@esbuild/aix-ppc64": "0.25.12",
4194 + "@esbuild/android-arm": "0.25.12",
4195 + "@esbuild/android-arm64": "0.25.12",
4196 + "@esbuild/android-x64": "0.25.12",
4197 + "@esbuild/darwin-arm64": "0.25.12",
4198 + "@esbuild/darwin-x64": "0.25.12",
4199 + "@esbuild/freebsd-arm64": "0.25.12",
4200 + "@esbuild/freebsd-x64": "0.25.12",
4201 + "@esbuild/linux-arm": "0.25.12",
4202 + "@esbuild/linux-arm64": "0.25.12",
4203 + "@esbuild/linux-ia32": "0.25.12",
4204 + "@esbuild/linux-loong64": "0.25.12",
4205 + "@esbuild/linux-mips64el": "0.25.12",
4206 + "@esbuild/linux-ppc64": "0.25.12",
4207 + "@esbuild/linux-riscv64": "0.25.12",
4208 + "@esbuild/linux-s390x": "0.25.12",
4209 + "@esbuild/linux-x64": "0.25.12",
4210 + "@esbuild/netbsd-arm64": "0.25.12",
4211 + "@esbuild/netbsd-x64": "0.25.12",
4212 + "@esbuild/openbsd-arm64": "0.25.12",
4213 + "@esbuild/openbsd-x64": "0.25.12",
4214 + "@esbuild/openharmony-arm64": "0.25.12",
4215 + "@esbuild/sunos-x64": "0.25.12",
4216 + "@esbuild/win32-arm64": "0.25.12",
4217 + "@esbuild/win32-ia32": "0.25.12",
4218 + "@esbuild/win32-x64": "0.25.12"
4219 + }
4220 + },
4221 + "node_modules/w3c-keyname": {
4222 + "version": "2.2.8",
4223 + "resolved": "https://registry.npmjs.org/w3c-keyname/-/w3c-keyname-2.2.8.tgz",
4224 + "integrity": "sha512-dpojBhNsCNN7T82Tm7k26A6G9ML3NkhDsnw9n/eoxSRlVBB4CEtIQ/KTCLI2Fwf3ataSXRhYFkQi3SlnFwPvPQ==",
4225 + "license": "MIT"
4226 },
2337 - "node_modules/shebang-command": {
2338 - "version": "2.0.0",
2339 - "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz",
2340 - "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==",
4227 + "node_modules/w3c-xmlserializer": {
4228 + "version": "5.0.0",
4229 + "resolved": "https://registry.npmjs.org/w3c-xmlserializer/-/w3c-xmlserializer-5.0.0.tgz",
4230 + "integrity": "sha512-o8qghlI8NZHU1lLPrpi2+Uq7abh4GGPpYANlalzWxyWteJOCsr/P+oPBA49TOLu5FTZO4d3F9MnWJfiMo4BkmA==",
4231 "dev": true,
4232 "license": "MIT",
4233 "dependencies": {
2344 - "shebang-regex": "^3.0.0"
4234 + "xml-name-validator": "^5.0.0"
4235 },
4236 "engines": {
2347 - "node": ">=8"
4237 + "node": ">=18"
4238 }
4239 },
2350 - "node_modules/shebang-regex": {
2351 - "version": "3.0.0",
2352 - "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz",
2353 - "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==",
4240 + "node_modules/webidl-conversions": {
4241 + "version": "7.0.0",
4242 + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-7.0.0.tgz",
4243 + "integrity": "sha512-VwddBukDzu71offAQR975unBIGqfKZpM+8ZX6ySk8nYhVoo5CYaZyzt3YBvYtRtO+aoGlqxPg/B87NGVZ/fu6g==",
4244 "dev": true,
2355 - "license": "MIT",
4245 + "license": "BSD-2-Clause",
4246 "engines": {
2357 - "node": ">=8"
4247 + "node": ">=12"
4248 }
4249 },
2360 - "node_modules/tslib": {
2361 - "version": "2.8.1",
2362 - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz",
2363 - "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==",
2364 - "dev": true,
2365 - "license": "0BSD",
2366 - "optional": true
2367 - },
2368 - "node_modules/type-check": {
2369 - "version": "0.4.0",
2370 - "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz",
2371 - "integrity": "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==",
4250 + "node_modules/whatwg-encoding": {
4251 + "version": "3.1.1",
4252 + "resolved": "https://registry.npmjs.org/whatwg-encoding/-/whatwg-encoding-3.1.1.tgz",
4253 + "integrity": "sha512-6qN4hJdMwfYBtE3YBTTHhoeuUrDBPZmbQaxWAqSALV/MeEnR5z1xd8UKud2RAkFoPkmB+hli1TZSnyi84xz1vQ==",
4254 + "deprecated": "Use @exodus/bytes instead for a more spec-conformant and faster implementation",
4255 "dev": true,
4256 "license": "MIT",
4257 "dependencies": {
2375 - "prelude-ls": "^1.2.1"
4258 + "iconv-lite": "0.6.3"
4259 },
4260 "engines": {
2378 - "node": ">= 0.8.0"
4261 + "node": ">=18"
4262 }
4263 },
2381 - "node_modules/undici": {
2382 - "version": "7.29.1",
2383 - "resolved": "https://registry.npmjs.org/undici/-/undici-7.29.1.tgz",
2384 - "integrity": "sha512-RYONW2MeafgYlkVOKYKkA/Ag7BmXqgIWCa8t1m0JcxrQg9pI9lEqRhAOruOBCbAohOa/gkCF+iPi9hrgvTzu6Q==",
4264 + "node_modules/whatwg-mimetype": {
4265 + "version": "4.0.0",
4266 + "resolved": "https://registry.npmjs.org/whatwg-mimetype/-/whatwg-mimetype-4.0.0.tgz",
4267 + "integrity": "sha512-QaKxh0eNIi2mE9p2vEdzfagOKHCcj1pJ56EEHGQOVxp8r9/iszLUUV7v89x9O1p/T+NlTM5W7jW6+cz4Fq1YVg==",
4268 "dev": true,
4269 "license": "MIT",
4270 "engines": {
2388 - "node": ">=20.18.1"
4271 + "node": ">=18"
4272 }
4273 },
2391 - "node_modules/unenv": {
2392 - "version": "2.0.0-rc.24",
2393 - "resolved": "https://registry.npmjs.org/unenv/-/unenv-2.0.0-rc.24.tgz",
2394 - "integrity": "sha512-i7qRCmY42zmCwnYlh9H2SvLEypEFGye5iRmEMKjcGi7zk9UquigRjFtTLz0TYqr0ZGLZhaMHl/foy1bZR+Cwlw==",
4274 + "node_modules/whatwg-url": {
4275 + "version": "14.2.0",
4276 + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-14.2.0.tgz",
4277 + "integrity": "sha512-De72GdQZzNTUBBChsXueQUnPKDkg/5A5zp7pFDuQAj5UFoENpiACU0wlCvzpAGnTkj++ihpKwKyYewn/XNUbKw==",
4278 "dev": true,
4279 "license": "MIT",
4280 "dependencies": {
2398 - "pathe": "^2.0.3"
2399 - }
2400 - },
2401 - "node_modules/uri-js": {
2402 - "version": "4.4.1",
2403 - "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz",
2404 - "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==",
2405 - "dev": true,
2406 - "license": "BSD-2-Clause",
2407 - "dependencies": {
2408 - "punycode": "^2.1.0"
4281 + "tr46": "^5.1.0",
4282 + "webidl-conversions": "^7.0.0"
4283 + },
4284 + "engines": {
4285 + "node": ">=18"
4286 }
4287 },
4288 "node_modules/which": {
@@ -2513,6 +4390,23 @@
4390 }
4391 }
4392 },
4393 + "node_modules/xml-name-validator": {
4394 + "version": "5.0.0",
4395 + "resolved": "https://registry.npmjs.org/xml-name-validator/-/xml-name-validator-5.0.0.tgz",
4396 + "integrity": "sha512-EvGK8EJ3DhaHfbRlETOWAS5pO9MZITeauHKJyb8wyajUfQUenkIg2MvLDTZ4T/TgIcm3HU0TFBgWWboAZ30UHg==",
4397 + "dev": true,
4398 + "license": "Apache-2.0",
4399 + "engines": {
4400 + "node": ">=18"
4401 + }
4402 + },
4403 + "node_modules/xmlchars": {
4404 + "version": "2.2.0",
4405 + "resolved": "https://registry.npmjs.org/xmlchars/-/xmlchars-2.2.0.tgz",
4406 + "integrity": "sha512-JZnDKK8B0RCDw84FNdDAIpZK+JuJw+s7Lz8nksI7SIuU3UXJJslUthsi+uWBUYOwPFwW7W7PRLRfUKpxjtjFCw==",
4407 + "dev": true,
4408 + "license": "MIT"
4409 + },
4410 "node_modules/yocto-queue": {
4411 "version": "0.1.0",
4412 "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz",
package.json
+25 -3
@@ -8,9 +8,12 @@
8 "test": "node --test test/*.test.js",
9 "start": "npx wrangler dev",
10 "lint": "eslint src test eslint.config.js",
11 - "format": "prettier --write \"src/**/*.js\" \"test/**/*.js\" \"*.config.js\" \"package*.json\" \"wrangler.jsonc\" \".github/workflows/*.yml\" \".prettierrc.json\"",
12 - "format:check": "prettier --check \"src/**/*.js\" \"test/**/*.js\" \"*.config.js\" \"package*.json\" \"wrangler.jsonc\" \".github/workflows/*.yml\" \".prettierrc.json\"",
13 - "build:check": "wrangler deploy --dry-run --outdir .wrangler/build-check"
11 + "format": "prettier --write \"src/**/*.js\" \"test/**/*.js\" \"web/**/*.{ts,tsx,css,html,json}\" \"*.config.js\" \"package*.json\" \"wrangler.jsonc\" \".github/workflows/*.yml\" \".prettierrc.json\"",
12 + "format:check": "prettier --check \"src/**/*.js\" \"test/**/*.js\" \"web/**/*.{ts,tsx,css,html,json}\" \"*.config.js\" \"package*.json\" \"wrangler.jsonc\" \".github/workflows/*.yml\" \".prettierrc.json\"",
13 + "web:check": "tsc -p web/tsconfig.json --noEmit",
14 + "build:web": "npm run web:check && vite build --config web/vite.config.ts",
15 + "dev:web": "vite --config web/vite.config.ts",
16 + "build:check": "npm run build:web && wrangler deploy --dry-run --outdir .wrangler/build-check"
17 },
18 "keywords": [
19 "telegram-bot",
@@ -22,9 +25,28 @@
25 "license": "MIT",
26 "devDependencies": {
27 "@eslint/js": "10.0.1",
28 + "@types/react": "19.2.2",
29 + "@types/react-dom": "19.2.2",
30 + "esbuild": "0.28.2",
31 "eslint": "10.13.0",
32 "globals": "16.5.0",
33 + "jsdom": "26.1.0",
34 "prettier": "3.6.2",
35 + "typescript": "5.9.3",
36 + "vite": "7.2.2",
37 "wrangler": "4.152.0"
38 + },
39 + "dependencies": {
40 + "@codemirror/commands": "6.8.1",
41 + "@codemirror/lang-css": "6.3.1",
42 + "@codemirror/lang-html": "6.4.10",
43 + "@codemirror/lang-javascript": "6.2.4",
44 + "@codemirror/lang-json": "6.0.2",
45 + "@codemirror/language": "6.11.3",
46 + "@codemirror/search": "6.5.11",
47 + "@codemirror/state": "6.5.2",
48 + "@codemirror/view": "6.38.6",
49 + "react": "19.2.0",
50 + "react-dom": "19.2.0"
51 }
52 }
src/config.js
+27
@@ -2,6 +2,7 @@ export const DEFAULT_CONFIG = {
2 defaultOwner: 'davoodmehraban89',
3 workspaceEditorUrl:
4 'https://nexa-dev-bot.davoodmehraban89.workers.dev/workspace/editor',
5 + studioAppUrl: 'https://nexa-dev-bot.davoodmehraban89.workers.dev/studio/',
6 devTools: [
7 {
8 id: 'ping',
@@ -11,6 +12,32 @@ export const DEFAULT_CONFIG = {
12 ]
13 };
14
15 +export function studioAppUrl(configured = DEFAULT_CONFIG.studioAppUrl) {
16 + if (
17 + typeof configured !== 'string' ||
18 + !configured.trim() ||
19 + configured.includes('?') ||
20 + configured.includes('#')
21 + )
22 + return '';
23 + try {
24 + const url = new URL(configured);
25 + if (
26 + url.protocol !== 'https:' ||
27 + url.username ||
28 + url.password ||
29 + url.search ||
30 + url.hash ||
31 + !['/studio', '/studio/'].includes(url.pathname)
32 + )
33 + return '';
34 + url.pathname = '/studio/';
35 + return url.href;
36 + } catch {
37 + return '';
38 + }
39 +}
40 +
41 export function workspaceEditorUrl(
42 configured = DEFAULT_CONFIG.workspaceEditorUrl
43 ) {
src/core/workspace-store.js
+22 -6
@@ -38,10 +38,14 @@ export class DurableWorkspaceStoreClient {
38 } catch {
39 body = null;
40 }
41 - if (!response.ok)
42 - throw new Error(
41 + if (!response.ok) {
42 + const error = new Error(
43 body?.error || `Durable workspace store failed (${response.status})`
44 );
45 + error.status = response.status;
46 + if (typeof body?.code === 'string') error.code = body.code;
47 + throw error;
48 + }
49 return body?.result ?? null;
50 }
51
@@ -67,12 +71,20 @@ export class DurableWorkspaceStoreClient {
71 upsertWorkspaceFile({ ownerId, workspaceId, file } = {}) {
72 return this.#call(ownerId, 'workspace/file/upsert', { workspaceId, file });
73 }
70 - updateWorkspaceFileDraft({ ownerId, workspaceId, path, text, digest } = {}) {
74 + updateWorkspaceFileDraft({
75 + ownerId,
76 + workspaceId,
77 + path,
78 + text,
79 + digest,
80 + expectedRevision
81 + } = {}) {
82 return this.#call(ownerId, 'workspace/file/draft', {
83 workspaceId,
84 path,
85 text,
75 - digest
86 + digest,
87 + expectedRevision
88 });
89 }
90 removeWorkspaceFile({ ownerId, workspaceId, path } = {}) {
@@ -94,8 +106,12 @@ export class DurableWorkspaceStoreClient {
106 digest
107 });
108 }
97 - sealIntent({ ownerId, workspaceId, intent } = {}) {
98 - return this.#call(ownerId, 'intent/seal', { workspaceId, intent });
109 + sealIntent({ ownerId, workspaceId, intent, expectedReview } = {}) {
110 + return this.#call(ownerId, 'intent/seal', {
111 + workspaceId,
112 + intent,
113 + expectedReview
114 + });
115 }
116 getIntent({ ownerId, intentId } = {}) {
117 return this.#call(ownerId, 'intent/get', { intentId });
src/durable/workspace-store.js
+294 -107
@@ -1,3 +1,5 @@
1 +import { WORKSPACE_EDITOR_LIMITS } from '../core/workspace-policy.js';
2 +
3 const json = (payload, status = 200) => Response.json(payload, { status });
4 const HANDLE_ALPHABET =
5 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-';
@@ -37,6 +39,78 @@ function normalizePath(value) {
39 throw new Error('Workspace file path is invalid');
40 return path;
41 }
42 +function fileRevision(file) {
43 + return Number.isSafeInteger(file?.revision) && file.revision >= 0
44 + ? file.revision
45 + : 0;
46 +}
47 +function nextRevision(revision) {
48 + if (!Number.isSafeInteger(revision) || revision >= Number.MAX_SAFE_INTEGER)
49 + throw new Error('Workspace file revision limit reached');
50 + return revision + 1;
51 +}
52 +function revisionConflict() {
53 + const error = new Error('Workspace file revision conflict');
54 + error.code = 'REVISION_CONFLICT';
55 + return error;
56 +}
57 +function assertExpectedRevision(payload, revision) {
58 + if (payload.expectedRevision === undefined) return;
59 + if (
60 + !Number.isSafeInteger(payload.expectedRevision) ||
61 + payload.expectedRevision < 0
62 + )
63 + throw new Error('Workspace file revision is invalid');
64 + if (payload.expectedRevision !== revision) throw revisionConflict();
65 +}
66 +function assertExpectedReview(expectedReview, workspace, proposed) {
67 + if (expectedReview === undefined) return;
68 + if (
69 + !expectedReview ||
70 + typeof expectedReview.baseHeadSha !== 'string' ||
71 + !Array.isArray(expectedReview.files)
72 + )
73 + throw new Error('Workspace review is invalid');
74 + const revisions = new Map();
75 + for (const file of expectedReview.files) {
76 + if (
77 + typeof file?.path !== 'string' ||
78 + !Number.isSafeInteger(file.revision) ||
79 + file.revision < 0 ||
80 + revisions.has(file.path)
81 + )
82 + throw new Error('Workspace review is invalid');
83 + revisions.set(file.path, file.revision);
84 + }
85 + if (
86 + expectedReview.baseHeadSha !== workspace.baseHeadSha ||
87 + (expectedReview.commitMessageDigest !== undefined &&
88 + expectedReview.commitMessageDigest !== workspace.commitMessageDigest) ||
89 + revisions.size !== workspace.files.length ||
90 + workspace.files.some(
91 + (file) => revisions.get(file.path) !== fileRevision(file)
92 + )
93 + )
94 + throw revisionConflict();
95 + if (
96 + expectedReview.commitMessageDigest !== undefined &&
97 + (proposed.workspaceId !== workspace.id ||
98 + Number(proposed.repoId) !== Number(workspace.repoId) ||
99 + proposed.baseBranch !== workspace.baseBranch ||
100 + proposed.baseHeadSha !== workspace.baseHeadSha ||
101 + proposed.baseTreeSha !== workspace.baseTreeSha ||
102 + proposed.commitMessageDigest !== workspace.commitMessageDigest ||
103 + !Array.isArray(proposed.files) ||
104 + proposed.files.length !== workspace.files.length ||
105 + workspace.files.some(
106 + (file, index) =>
107 + proposed.files[index]?.path !== file.path ||
108 + proposed.files[index]?.sourceBlobSha !== file.blobSha ||
109 + proposed.files[index]?.contentDigest !== file.draftDigest
110 + ))
111 + )
112 + throw revisionConflict();
113 +}
114 function legacyFile(payload) {
115 return {
116 path: normalizePath(payload.path),
@@ -44,12 +118,20 @@ function legacyFile(payload) {
118 originalText: String(payload.originalText ?? ''),
119 originalDigest: String(payload.originalDigest || ''),
120 draftText: String(payload.originalText ?? ''),
47 - draftDigest: String(payload.originalDigest || '')
121 + draftDigest: String(payload.originalDigest || ''),
122 + revision: 0
123 };
124 }
125 function migrate(ws) {
126 if (!ws) return ws;
52 - if (Array.isArray(ws.files)) return ws;
127 + if (Array.isArray(ws.files))
128 + return {
129 + ...ws,
130 + files: ws.files.map((file) => ({
131 + ...file,
132 + revision: fileRevision(file)
133 + }))
134 + };
135 return {
136 ...ws,
137 schemaVersion: 2,
@@ -60,7 +142,8 @@ function migrate(ws) {
142 originalText: String(ws.originalText ?? ''),
143 originalDigest: String(ws.originalDigest || ''),
144 draftText: String(ws.draftText ?? ws.originalText ?? ''),
63 - draftDigest: String(ws.draftDigest || ws.originalDigest || '')
145 + draftDigest: String(ws.draftDigest || ws.originalDigest || ''),
146 + revision: 0
147 }
148 ]
149 };
@@ -85,6 +168,24 @@ function validateFiles(files) {
168 }
169 if (bytes(files) > MAX_WORKSPACE_BYTES)
170 throw new Error('Workspace aggregate size is too large');
171 + const encoder = new TextEncoder(),
172 + aggregateBytes = files.reduce(
173 + (total, file) =>
174 + total +
175 + Math.max(
176 + encoder.encode(String(file.originalText ?? '')).byteLength,
177 + encoder.encode(String(file.draftText ?? '')).byteLength
178 + ),
179 + 0
180 + );
181 + if (
182 + files.length > WORKSPACE_EDITOR_LIMITS.maxFiles ||
183 + aggregateBytes > WORKSPACE_EDITOR_LIMITS.maxAggregateBytes
184 + ) {
185 + const error = new Error('Workspace aggregate text or file limit exceeded');
186 + error.code = 'WORKSPACE_LIMIT_EXCEEDED';
187 + throw error;
188 + }
189 }
190
191 export class WorkspaceStore {
@@ -163,9 +264,17 @@ export class WorkspaceStore {
264 return new Response('Not Found', { status: 404 });
265 }
266 } catch (error) {
267 + const status = {
268 + REVISION_CONFLICT: 409,
269 + WORKSPACE_NOT_EDITABLE: 409,
270 + WORKSPACE_LIMIT_EXCEEDED: 422
271 + }[error?.code];
272 return json(
167 - { error: String(error?.message || 'Workspace store operation failed') },
168 - 400
273 + {
274 + error: String(error?.message || 'Workspace store operation failed'),
275 + ...(status ? { code: error.code } : {})
276 + },
277 + status || 400
278 );
279 }
280 }
@@ -178,12 +287,12 @@ export class WorkspaceStore {
287 await this.state.storage.setAlarm(expiry);
288 }
289 }
181 - async #getExpiring(key, now) {
290 + async #getExpiring(key, now, storage = this.state.storage) {
291 if (!key || key.endsWith(':')) return null;
183 - const record = await this.state.storage.get(key);
292 + const record = await storage.get(key);
293 if (!record) return null;
294 if (expired(record, now)) {
186 - await this.state.storage.delete(key);
295 + await storage.delete(key);
296 return null;
297 }
298 return record;
@@ -256,12 +365,30 @@ export class WorkspaceStore {
365 await this.#schedule(expiresAt);
366 return workspace;
367 }
259 - async #requireWorkspace(id, now) {
260 - const ws = migrate(await this.#getExpiring(`ws:${String(id || '')}`, now));
368 + async #requireWorkspace(id, now, storage = this.state.storage) {
369 + const ws = migrate(
370 + await this.#getExpiring(`ws:${String(id || '')}`, now, storage)
371 + );
372 if (!ws) throw new Error('Workspace not found or expired');
373 return ws;
374 }
264 - async #saveMaterial(ws, files, now) {
375 + async #requireEditableWorkspace(id, now, storage) {
376 + const workspace = await this.#requireWorkspace(id, now, storage);
377 + const intent = workspace.currentIntentId
378 + ? await storage.get(`intent:${workspace.currentIntentId}`)
379 + : null;
380 + if (
381 + [workspace.state, intent?.state].some((state) =>
382 + ['COMMITTING', 'COMMITTED'].includes(state)
383 + )
384 + ) {
385 + const error = new Error('Workspace is not editable');
386 + error.code = 'WORKSPACE_NOT_EDITABLE';
387 + throw error;
388 + }
389 + return workspace;
390 + }
391 + async #saveMaterial(ws, files, now, storage, materialChanged = true) {
392 validateFiles(files);
393 const primary = files[0];
394 const updated = {
@@ -274,83 +401,134 @@ export class WorkspaceStore {
401 originalDigest: primary.originalDigest,
402 draftText: primary.draftText,
403 draftDigest: primary.draftDigest,
277 - currentIntentId: null,
278 - state: 'DRAFT',
404 + ...(materialChanged ? { currentIntentId: null, state: 'DRAFT' } : {}),
405 updatedAt: now
406 };
281 - await this.state.storage.put(`ws:${ws.id}`, updated);
407 + await storage.put(`ws:${ws.id}`, updated);
408 return updated;
409 }
410 async #upsertFile(payload, now) {
285 - const ws = await this.#requireWorkspace(payload.workspaceId, now),
286 - source = payload.file || {},
287 - path = normalizePath(source.path);
288 - if (ws.files.some((f) => normalizePath(f.path) === path))
289 - throw new Error('Workspace file path already exists');
290 - const file = {
291 - path,
292 - blobSha: String(source.blobSha || ''),
293 - originalText: String(source.originalText ?? ''),
294 - originalDigest: String(source.originalDigest || ''),
295 - draftText: String(source.draftText ?? source.originalText ?? ''),
296 - draftDigest: String(source.draftDigest || source.originalDigest || '')
297 - };
298 - return this.#saveMaterial(ws, [...ws.files, file], now);
411 + return this.state.storage.transaction(async (txn) => {
412 + const ws = await this.#requireEditableWorkspace(
413 + payload.workspaceId,
414 + now,
415 + txn
416 + ),
417 + source = payload.file || {},
418 + path = normalizePath(source.path);
419 + if (ws.files.some((f) => normalizePath(f.path) === path))
420 + throw new Error('Workspace file path already exists');
421 + const file = {
422 + path,
423 + blobSha: String(source.blobSha || ''),
424 + originalText: String(source.originalText ?? ''),
425 + originalDigest: String(source.originalDigest || ''),
426 + draftText: String(source.draftText ?? source.originalText ?? ''),
427 + draftDigest: String(source.draftDigest || source.originalDigest || ''),
428 + revision: fileRevision({ revision: ws.fileRevisionFloor })
429 + };
430 + return this.#saveMaterial(ws, [...ws.files, file], now, txn);
431 + });
432 }
433 async #updateFileDraft(payload, now) {
301 - const ws = await this.#requireWorkspace(payload.workspaceId, now),
302 - path = normalizePath(payload.path),
303 - digest = String(payload.digest || '');
304 - if (!digest) throw new Error('Draft digest is required');
305 - let found = false;
306 - const files = ws.files.map((f) =>
307 - normalizePath(f.path) === path
308 - ? ((found = true),
309 - { ...f, draftText: String(payload.text ?? ''), draftDigest: digest })
310 - : f
311 - );
312 - if (!found) throw new Error('Workspace file not found');
313 - if (
314 - ws.files.find((f) => normalizePath(f.path) === path)?.draftDigest ===
315 - digest
316 - )
317 - return ws;
318 - return this.#saveMaterial(ws, files, now);
434 + return this.state.storage.transaction(async (txn) => {
435 + const ws = await this.#requireEditableWorkspace(
436 + payload.workspaceId,
437 + now,
438 + txn
439 + ),
440 + path = normalizePath(payload.path),
441 + digest = String(payload.digest || '');
442 + if (!digest) throw new Error('Draft digest is required');
443 + const file = ws.files.find((f) => normalizePath(f.path) === path);
444 + if (!file) throw new Error('Workspace file not found');
445 + assertExpectedRevision(payload, fileRevision(file));
446 + const changed = file.draftDigest !== digest,
447 + files = ws.files.map((f) =>
448 + f === file
449 + ? {
450 + ...f,
451 + ...(changed
452 + ? {
453 + draftText: String(payload.text ?? ''),
454 + draftDigest: digest
455 + }
456 + : {}),
457 + revision: nextRevision(fileRevision(f))
458 + }
459 + : f
460 + );
461 + return this.#saveMaterial(ws, files, now, txn, changed);
462 + });
463 }
464 async #removeFile(payload, now) {
321 - const ws = await this.#requireWorkspace(payload.workspaceId, now),
322 - path = normalizePath(payload.path),
323 - files = ws.files.filter((f) => normalizePath(f.path) !== path);
324 - if (files.length === ws.files.length)
325 - throw new Error('Workspace file not found');
326 - return this.#saveMaterial(ws, files, now);
465 + return this.state.storage.transaction(async (txn) => {
466 + const ws = await this.#requireEditableWorkspace(
467 + payload.workspaceId,
468 + now,
469 + txn
470 + ),
471 + path = normalizePath(payload.path),
472 + files = ws.files.filter((f) => normalizePath(f.path) !== path);
473 + if (files.length === ws.files.length)
474 + throw new Error('Workspace file not found');
475 + // A scalar floor prevents stale revisions matching a removed/readded path.
476 + const fileRevisionFloor = nextRevision(
477 + Math.max(
478 + fileRevision({ revision: ws.fileRevisionFloor }),
479 + ...ws.files.map(fileRevision)
480 + )
481 + );
482 + return this.#saveMaterial({ ...ws, fileRevisionFloor }, files, now, txn);
483 + });
484 }
485 async #updateDraft(payload, now) {
329 - const ws = await this.#requireWorkspace(payload.workspaceId, now),
330 - digest = String(payload.digest || '');
331 - if (!digest) throw new Error('Draft digest is required');
332 - if (digest === ws.draftDigest) return ws;
333 - const files = ws.files.map((f, i) =>
334 - i
335 - ? f
336 - : { ...f, draftText: String(payload.text ?? ''), draftDigest: digest }
337 - );
338 - return this.#saveMaterial(ws, files, now);
486 + return this.state.storage.transaction(async (txn) => {
487 + const ws = await this.#requireEditableWorkspace(
488 + payload.workspaceId,
489 + now,
490 + txn
491 + ),
492 + digest = String(payload.digest || '');
493 + if (!digest) throw new Error('Draft digest is required');
494 + const changed = digest !== ws.draftDigest,
495 + files = ws.files.map((f, i) =>
496 + i
497 + ? f
498 + : {
499 + ...f,
500 + ...(changed
501 + ? {
502 + draftText: String(payload.text ?? ''),
503 + draftDigest: digest
504 + }
505 + : {}),
506 + revision: nextRevision(fileRevision(f))
507 + }
508 + );
509 + return this.#saveMaterial(ws, files, now, txn, changed);
510 + });
511 }
512 async #setCommitMessage(payload, now) {
341 - const ws = await this.#requireWorkspace(payload.workspaceId, now),
342 - digest = String(payload.digest || '');
343 - if (!digest) throw new Error('Commit message digest is required');
344 - const changed = digest !== ws.commitMessageDigest,
345 - updated = {
346 - ...ws,
347 - commitMessage: String(payload.message || ''),
348 - commitMessageDigest: digest,
349 - updatedAt: now,
350 - ...(changed ? { currentIntentId: null, state: 'DRAFT' } : {})
351 - };
352 - await this.state.storage.put(`ws:${ws.id}`, updated);
353 - return updated;
513 + return this.state.storage.transaction(async (txn) => {
514 + const ws = await this.#requireEditableWorkspace(
515 + payload.workspaceId,
516 + now,
517 + txn
518 + ),
519 + digest = String(payload.digest || '');
520 + if (!digest) throw new Error('Commit message digest is required');
521 + const changed = digest !== ws.commitMessageDigest,
522 + updated = {
523 + ...ws,
524 + commitMessage: String(payload.message || ''),
525 + commitMessageDigest: digest,
526 + updatedAt: now,
527 + ...(changed ? { currentIntentId: null, state: 'DRAFT' } : {})
528 + };
529 + await txn.put(`ws:${ws.id}`, updated);
530 + return updated;
531 + });
532 }
533 async #setPending(payload, now) {
534 const ws = await this.#requireWorkspace(payload.workspaceId, now),
@@ -393,39 +571,48 @@ export class WorkspaceStore {
571 });
572 }
573 async #sealIntent(payload, now) {
396 - const ws = await this.#requireWorkspace(payload.workspaceId, now),
397 - proposed =
398 - payload.intent && typeof payload.intent === 'object'
399 - ? payload.intent
400 - : null;
401 - if (!proposed?.intentDigest)
402 - throw new Error('Commit intent digest is required');
403 - if (ws.currentIntentId) {
404 - const existing = await this.#getExpiring(
405 - `intent:${ws.currentIntentId}`,
406 - now
407 - );
408 - if (existing?.intentDigest === proposed.intentDigest) return existing;
409 - }
410 - const id = randomHandle(8),
411 - intent = {
412 - ...proposed,
413 - id,
414 - workspaceId: ws.id,
574 + const intent = await this.state.storage.transaction(async (txn) => {
575 + const ws = await this.#requireEditableWorkspace(
576 + payload.workspaceId,
577 + now,
578 + txn
579 + ),
580 + proposed =
581 + payload.intent && typeof payload.intent === 'object'
582 + ? payload.intent
583 + : null;
584 + if (!proposed?.intentDigest)
585 + throw new Error('Commit intent digest is required');
586 + assertExpectedReview(payload.expectedReview, ws, proposed);
587 + if (ws.currentIntentId) {
588 + const existing = await this.#getExpiring(
589 + `intent:${ws.currentIntentId}`,
590 + now,
591 + txn
592 + );
593 + if (existing?.intentDigest === proposed.intentDigest) return existing;
594 + }
595 + const id = randomHandle(8),
596 + created = {
597 + ...proposed,
598 + id,
599 + workspaceId: ws.id,
600 + state: 'READY',
601 + candidateCommitSha: null,
602 + commitSha: null,
603 + branch: null,
604 + createdAt: now,
605 + updatedAt: now,
606 + expiresAt: ws.expiresAt
607 + };
608 + await txn.put(`intent:${id}`, created);
609 + await txn.put(`ws:${ws.id}`, {
610 + ...ws,
611 + currentIntentId: id,
612 state: 'READY',
416 - candidateCommitSha: null,
417 - commitSha: null,
418 - branch: null,
419 - createdAt: now,
420 - updatedAt: now,
421 - expiresAt: ws.expiresAt
422 - };
423 - await this.state.storage.put(`intent:${id}`, intent);
424 - await this.state.storage.put(`ws:${ws.id}`, {
425 - ...ws,
426 - currentIntentId: id,
427 - state: 'READY',
428 - updatedAt: now
613 + updatedAt: now
614 + });
615 + return created;
616 });
617 await this.#schedule(intent.expiresAt);
618 return intent;
src/github.js
+76 -10
@@ -70,7 +70,13 @@ export class GitHubService {
70 async requestJson(
71 url,
72 label,
73 - { method = 'GET', body, allowEmpty = false, allowNotFound = false } = {}
73 + {
74 + method = 'GET',
75 + body,
76 + allowEmpty = false,
77 + allowNotFound = false,
78 + includeHeaders = false
79 + } = {}
80 ) {
81 const headers = this.getHeaders();
82 const options = { method, headers };
@@ -100,7 +106,7 @@ export class GitHubService {
106 if (!raw) return null;
107 if (parsed === null)
108 throw new Error(`${label} failed: invalid JSON response`);
103 - return parsed;
109 + return includeHeaders ? { data: parsed, headers: res.headers } : parsed;
110 }
111 async requestText(url, label, { maxChars = 12000 } = {}) {
112 const res = await fetch(url, { method: 'GET', headers: this.getHeaders() });
@@ -222,14 +228,74 @@ export class GitHubService {
228 };
229 }
230 async listRepositories() {
225 - const data = await this.requestJson(
226 - `${this.baseUrl}/user/repos?sort=updated&per_page=20&affiliation=owner,collaborator,organization_member`,
227 - 'GitHub repositories'
228 - );
229 - return data.map((r) => {
230 - const repo = this.mapRepository(r);
231 - return { ...repo, title: `${repo.name} ${repo.private ? '🔒' : '🌐'}` };
232 - });
231 + const endpoint = new URL(`${this.baseUrl}/user/repos`);
232 + let next = `${endpoint.href}?sort=updated&per_page=100&affiliation=owner,collaborator,organization_member`;
233 + let page = 1;
234 + const repositories = [];
235 + const visited = new Set();
236 + while (next) {
237 + if (visited.has(next))
238 + throw new Error('GitHub repository pagination repeated a page');
239 + visited.add(next);
240 + const { data, headers } = await this.requestJson(
241 + next,
242 + 'GitHub repositories',
243 + { includeHeaders: true }
244 + );
245 + if (!Array.isArray(data))
246 + throw new Error('GitHub repository page is not a repository listing');
247 + repositories.push(
248 + ...data.map((r) => {
249 + const repo = this.mapRepository(r);
250 + return {
251 + ...repo,
252 + title: `${repo.name} ${repo.private ? '🔒' : '🌐'}`
253 + };
254 + })
255 + );
256 + const link = headers.get('link');
257 + next = '';
258 + if (!link) continue;
259 + for (const part of link.split(/,(?=\s*<)/)) {
260 + const match = part.trim().match(/^<([^>]+)>\s*((?:;[^<>]*)*)$/);
261 + if (!match)
262 + throw new Error('GitHub repository pagination Link is invalid');
263 + const relation = match[2].match(
264 + /(?:^|;)\s*rel\s*=\s*(?:"([^"]*)"|([^;\s]+))/i
265 + );
266 + if (
267 + !relation ||
268 + !(relation[1] || relation[2]).split(/\s+/).includes('next')
269 + )
270 + continue;
271 + if (next)
272 + throw new Error(
273 + 'GitHub repository pagination has multiple next pages'
274 + );
275 + let target;
276 + try {
277 + target = new URL(match[1], endpoint);
278 + } catch {
279 + throw new Error('GitHub repository pagination URL is invalid');
280 + }
281 + const nextPage = target.searchParams.get('page') || '';
282 + if (
283 + target.origin !== endpoint.origin ||
284 + target.pathname !== endpoint.pathname ||
285 + target.username ||
286 + target.password ||
287 + target.hash ||
288 + target.searchParams.get('per_page') !== '100' ||
289 + !/^[1-9][0-9]*$/.test(nextPage) ||
290 + !Number.isSafeInteger(Number(nextPage)) ||
291 + Number(nextPage) <= page
292 + )
293 + throw new Error('GitHub repository pagination target is invalid');
294 + page = Number(nextPage);
295 + next = target.href;
296 + }
297 + }
298 + return repositories;
299 }
300 async getRepository(repoRef) {
301 const { raw } = await this.getRepositoryContext(repoRef);
src/guide-bot.js
+123 -21
@@ -2,19 +2,39 @@ import { NexaDevBot } from './bot.js';
2 import { CloudflareMenuManager } from './cloudflare-menu.js';
3 import { RuntimeDiagnostics } from './core/runtime-diagnostics.js';
4 import { platformHomeView, platformCapabilityView } from './platform-menu.js';
5 +import { studioAppUrl } from './config.js';
6 +import { interceptTelegramSecretMessage } from './core/telegram-secret-guard.js';
7
6 -function guidedPersistentQuickMenuMarkup() {
7 - return {
8 - keyboard: [
9 - [{ text: '🏠 منوی اصلی' }, { text: '📁 پروژه‌ها' }],
10 - [{ text: '📊 وضعیت' }, { text: '🔧 ابزارها' }],
11 - [{ text: '🧭 پلتفرم' }, { text: '🔐 امنیت' }],
12 - [{ text: '📘 راهنما' }]
13 - ],
14 - resize_keyboard: true,
15 - is_persistent: true,
16 - input_field_placeholder: 'Nexa Dev — یک گزینه را انتخاب کنید'
17 - };
8 +const STUDIO_URL_ERROR =
9 + '⚠️ نشانی Nexa Studio پیکربندی نشده است. با مدیر ربات تماس بگیرید.';
10 +
11 +function isOwnerPrivateChat(ownerId, from, chat) {
12 + return (
13 + Boolean(ownerId) &&
14 + from?.id !== undefined &&
15 + from?.id !== null &&
16 + String(from.id) === String(ownerId) &&
17 + chat?.type === 'private' &&
18 + Number.isSafeInteger(chat.id) &&
19 + chat.id > 0 &&
20 + String(chat.id) === String(ownerId)
21 + );
22 +}
23 +
24 +function studioEntryView(url) {
25 + return url
26 + ? {
27 + text: 'برای کار با پروژه‌ها، Nexa Studio را با دکمه زیر باز کنید.\nتوکن و متن کد را در چت نفرستید.',
28 + reply_markup: {
29 + inline_keyboard: [
30 + [{ text: 'باز کردن Nexa Studio', web_app: { url } }]
31 + ]
32 + }
33 + }
34 + : {
35 + text: STUDIO_URL_ERROR,
36 + reply_markup: { inline_keyboard: [] }
37 + };
38 }
39 export class GuidedNexaDevBot extends NexaDevBot {
40 constructor(env = {}) {
@@ -30,17 +50,57 @@ export class GuidedNexaDevBot extends NexaDevBot {
50 this.menu = new CloudflareMenuManager(this.github, this.diagnostics);
51 }
52 async handleMessage(message) {
53 + const intercepted = await interceptTelegramSecretMessage({
54 + message,
55 + telegram: this.telegram,
56 + ownerId: this.env.OWNER_TELEGRAM_ID
57 + });
58 + if (intercepted) return intercepted;
59 const chatId = message?.chat?.id,
60 rawText = typeof message?.text === 'string' ? message.text : '',
61 text = rawText.trim();
36 - if (!chatId) return super.handleMessage(message);
37 - if (text === '/start' || text === '/menu' || text.startsWith('/start')) {
38 - const quickMenuRes = await this.telegram.sendMessage(
62 + const startCommand = /^\/start(?:@[A-Za-z0-9_]+)?(?:\s|$)/.test(text);
63 + const menuCommand = /^\/menu(?:@[A-Za-z0-9_]+)?$/.test(text);
64 + if (startCommand || menuCommand || text === '🏠 منوی اصلی') {
65 + if (
66 + !isOwnerPrivateChat(
67 + this.env.OWNER_TELEGRAM_ID,
68 + message?.from,
69 + message?.chat
70 + )
71 + )
72 + return {
73 + ok: false,
74 + studioEntry: true,
75 + reason: 'owner_private_chat_required'
76 + };
77 + const url = studioAppUrl(this.env.STUDIO_URL);
78 + if (!url) {
79 + const res = await this.telegram.sendMessage(chatId, STUDIO_URL_ERROR, {
80 + remove_keyboard: true
81 + });
82 + return { ok: false, studioEntry: true, invalidStudioUrl: true, res };
83 + }
84 + const welcomeRes = await this.telegram.sendMessage(
85 chatId,
40 - '⌨️ <b>منوی سریع Nexa Dev فعال شد</b>\nاین منو پایین صفحه می‌ماند و «📘 راهنما» از هر بخش در دسترس است.',
41 - guidedPersistentQuickMenuMarkup()
86 + 'به Nexa Studio خوش آمدید.',
87 + { remove_keyboard: true }
88 );
43 - const view = this.menu.getMainMenuView();
89 + let menuButtonConfigured;
90 + if (startCommand) {
91 + menuButtonConfigured = false;
92 + try {
93 + await this.telegram.setChatMenuButton(chatId, {
94 + type: 'web_app',
95 + text: 'Nexa Studio',
96 + web_app: { url }
97 + });
98 + menuButtonConfigured = true;
99 + } catch {
100 + // Telegram menu setup is optional; never expose provider errors.
101 + }
102 + }
103 + const view = studioEntryView(url);
104 const res = await this.telegram.sendMessage(
105 chatId,
106 view.text,
@@ -48,12 +108,16 @@ export class GuidedNexaDevBot extends NexaDevBot {
108 );
109 return {
110 ok: true,
51 - command: 'start',
52 - persistentMenu: true,
53 - quickMenuRes,
111 + ...(text === '🏠 منوی اصلی'
112 + ? { quickMenu: 'main' }
113 + : { command: 'start' }),
114 + studioEntry: true,
115 + ...(startCommand ? { menuButtonConfigured } : {}),
116 + welcomeRes,
117 res
118 };
119 }
120 + if (!chatId) return super.handleMessage(message);
121 if (text === '📘 راهنما' || text === '/help') {
122 const view = this.menu.getGuideIndexView();
123 const res = await this.telegram.sendMessage(
@@ -76,6 +140,44 @@ export class GuidedNexaDevBot extends NexaDevBot {
140 }
141 async handleCallbackQuery(query) {
142 const data = query?.data || '';
143 + if (data === 'menu:main') {
144 + const message = query?.message;
145 + if (
146 + !isOwnerPrivateChat(
147 + this.env.OWNER_TELEGRAM_ID,
148 + query?.from,
149 + message?.chat
150 + ) ||
151 + !Number.isSafeInteger(message?.message_id)
152 + )
153 + return {
154 + ok: false,
155 + studioEntry: true,
156 + reason: 'owner_private_chat_required'
157 + };
158 + let callbackAnswered = true;
159 + try {
160 + await this.telegram.answerCallbackQuery(query.id);
161 + } catch {
162 + callbackAnswered = false;
163 + }
164 + const url = studioAppUrl(this.env.STUDIO_URL);
165 + const view = studioEntryView(url);
166 + const res = await this.telegram.editMessageText(
167 + message.chat.id,
168 + message.message_id,
169 + view.text,
170 + view.reply_markup
171 + );
172 + return {
173 + ok: Boolean(url),
174 + studioEntry: true,
175 + ...(!url ? { invalidStudioUrl: true } : {}),
176 + callbackAnswered,
177 + edited: true,
178 + res
179 + };
180 + }
181 if (data === 'menu:platform' || data.startsWith('platform:')) {
182 const view =
183 data === 'menu:platform'
src/index.js
+25 -5
@@ -2,6 +2,8 @@ import { KillSwitchGuidedNexaDevBot } from './kill-switch-bot.js';
2 import { DurableWorkspaceStoreClient } from './core/workspace-store.js';
3 import { RELEASE_VERSION } from './version.js';
4 import { GitHubService } from './github.js';
5 +import { handleStudioAssetsRequest } from './studio-assets.js';
6 +import { handleStudioApiRequest } from './studio-api.js';
7 import {
8 consumeTelegramUpdate,
9 telegramBotIdentity
@@ -35,9 +37,29 @@ const isOwnerUpdate = (u, e) =>
37 !!e.OWNER_TELEGRAM_ID &&
38 senderIdFromUpdate(u) !== null &&
39 String(senderIdFromUpdate(u)) === String(e.OWNER_TELEGRAM_ID);
40 +const botEnvironment = (env, url) => ({
41 + ...env,
42 + STUDIO_URL: env.STUDIO_URL ?? new URL('/studio/', url).href,
43 + WORKSPACE_EDITOR_URL:
44 + env.WORKSPACE_EDITOR_URL ?? new URL('/workspace/editor', url).href
45 +});
46 export default {
47 async fetch(request, env = {}) {
48 const url = new URL(request.url);
49 + const studioAssets = await handleStudioAssetsRequest(request, env);
50 + if (studioAssets) return studioAssets;
51 + if (
52 + url.pathname === '/api/v1/studio' ||
53 + url.pathname.startsWith('/api/v1/studio/')
54 + ) {
55 + const bot = new KillSwitchGuidedNexaDevBot(botEnvironment(env, url));
56 + return handleStudioApiRequest(request, {
57 + env,
58 + github: bot.github,
59 + workspaces: bot.workspaceStore,
60 + bot
61 + });
62 + }
63 if (request.method === 'GET' && url.pathname === '/workspace/editor')
64 return workspaceEditorPageResponse();
65 if (
@@ -115,11 +137,9 @@ export default {
137 // Claim before effects: retries are at-most-once; a process crash after the
138 // durable claim can lose this update. No raw update is retained for replay.
139 try {
118 - const result = await new KillSwitchGuidedNexaDevBot({
119 - ...env,
120 - WORKSPACE_EDITOR_URL:
121 - env.WORKSPACE_EDITOR_URL ?? new URL('/workspace/editor', url).href
122 - }).handleUpdate(update);
140 + const result = await new KillSwitchGuidedNexaDevBot(
141 + botEnvironment(env, url)
142 + ).handleUpdate(update);
143 if (result?.ok !== false) return jsonResponse(result);
144 } catch {
145 // Provider messages can contain tokens or draft text; log metadata only.
src/plugins/github/workspace.js
+62 -9
@@ -1,4 +1,5 @@
1 import {
2 + WORKSPACE_EDITOR_LIMITS,
3 buildUnifiedDiff,
4 digestText,
5 makeTargetBranch,
@@ -290,7 +291,7 @@ export function createWorkspaceController({
291 };
292 };
293
293 - const createDraft = async (refId, ownerId) => {
294 + const createWorkspaceFromRef = async (refId, ownerId) => {
295 const ref = await workspaces.resolveNavigationRef({ ownerId, refId });
296 if (!ref || ref.type !== 'file')
297 throw new Error('Workspace file reference is missing or expired');
@@ -304,7 +305,7 @@ export function createWorkspaceController({
305 if (!policy.editable)
306 throw new Error(policy.reason || 'File is not editable');
307 const originalDigest = await digestText(file.content);
307 - const workspace = await workspaces.createWorkspace({
308 + return workspaces.createWorkspace({
309 ownerId,
310 repoId: Number(ref.repoId),
311 repoFullName: repo.fullName,
@@ -316,12 +317,16 @@ export function createWorkspaceController({
317 originalText: file.content,
318 originalDigest
319 });
320 + };
321 +
322 + const createDraft = async (refId, ownerId) => {
323 + const workspace = await createWorkspaceFromRef(refId, ownerId);
324 return {
320 - text: `📝 <b>Draft ساخته شد</b>\nمخزن: <code>${escapeHtml(repo.fullName)}</code>\nفایل: <code>${escapeHtml(file.path)}</code>\nBase: <code>${escapeHtml(snapshot.headSha.slice(0, 10))}</code>\n\nهنوز هیچ تغییری در GitHub انجام نشده است.`,
325 + text: `📝 <b>Draft ساخته شد</b>\nمخزن: <code>${escapeHtml(workspace.repoFullName)}</code>\nفایل: <code>${escapeHtml(workspace.path)}</code>\nBase: <code>${escapeHtml(workspace.baseHeadSha.slice(0, 10))}</code>\n\nهنوز هیچ تغییری در GitHub انجام نشده است.`,
326 reply_markup: {
327 inline_keyboard: [
328 [{ text: '📝 باز کردن Draft', callback_data: `ws:${workspace.id}` }],
324 - [{ text: '🔙 فایل‌ها', callback_data: `files:${ref.repoId}` }]
329 + [{ text: '🔙 فایل‌ها', callback_data: `files:${workspace.repoId}` }]
330 ]
331 }
332 };
@@ -442,11 +447,21 @@ export function createWorkspaceController({
447 };
448 };
449
445 - const addWorkspaceFile = async (refId, ownerId) => {
450 + const addWorkspaceFileFromRef = async (
451 + refId,
452 + ownerId,
453 + expectedWorkspaceId = null
454 + ) => {
455 const ref = await workspaces.resolveNavigationRef({ ownerId, refId });
456 if (!ref || ref.type !== 'workspace-add')
457 throw new Error('Workspace add-file reference is missing or expired');
458 + if (expectedWorkspaceId && ref.workspaceId !== expectedWorkspaceId)
459 + throw new Error('Workspace reference mismatch');
460 const workspace = await requireWorkspace(ref.workspaceId, ownerId);
461 + if (Number(workspace.repoId) !== Number(ref.repoId))
462 + throw new Error('Workspace repository mismatch');
463 + if (workspace.files.length >= WORKSPACE_EDITOR_LIMITS.maxFiles)
464 + throw new Error('Workspace file count is limited');
465 const file = await github.getFileAtRef(
466 ref.repoId,
467 ref.path,
@@ -459,8 +474,19 @@ export function createWorkspaceController({
474 });
475 if (!policy.editable)
476 throw new Error(policy.reason || 'File is not editable');
477 + const aggregateBytes = workspace.files.reduce(
478 + (total, entry) =>
479 + total +
480 + Math.max(
481 + new TextEncoder().encode(entry.originalText ?? '').byteLength,
482 + new TextEncoder().encode(entry.draftText ?? '').byteLength
483 + ),
484 + policy.byteLength
485 + );
486 + if (aggregateBytes > WORKSPACE_EDITOR_LIMITS.maxAggregateBytes)
487 + throw new Error('Workspace aggregate size is limited');
488 const digest = await digestText(file.content);
463 - const updated = await workspaces.upsertWorkspaceFile({
489 + return workspaces.upsertWorkspaceFile({
490 ownerId,
491 workspaceId: workspace.id,
492 file: {
@@ -472,8 +498,12 @@ export function createWorkspaceController({
498 draftDigest: digest
499 }
500 });
501 + };
502 +
503 + const addWorkspaceFile = async (refId, ownerId) => {
504 + const updated = await addWorkspaceFileFromRef(refId, ownerId);
505 const view = await renderWorkspaceObject(updated, ownerId);
476 - view.text = `✅ فایل <code>${escapeHtml(file.path)}</code> اضافه شد.\n\n${view.text}`;
506 + view.text = `✅ فایل به Change Set اضافه شد.\n\n${view.text}`;
507 return view;
508 };
509
@@ -631,7 +661,7 @@ export function createWorkspaceController({
661 };
662 };
663
634 - const sealReadyIntent = async (workspaceId, ownerId) => {
664 + const sealWorkspaceIntent = async (workspaceId, ownerId, review) => {
665 const workspace = await requireWorkspace(workspaceId, ownerId);
666 const workspaceFiles =
667 Array.isArray(workspace.files) && workspace.files.length
@@ -692,10 +722,17 @@ export function createWorkspaceController({
722 const intent = await workspaces.sealIntent({
723 ownerId,
724 workspaceId,
695 - intent: { ...material, intentDigest }
725 + intent: { ...material, intentDigest },
726 + ...(review ? { expectedReview: review } : {})
727 });
728 if (!intent?.id || !/^[A-Za-z0-9_-]{8}$/.test(intent.id))
729 throw new Error('Commit intent ID is invalid');
730 + return { workspace, workspaceFiles, changedFiles, targetBranch, intent };
731 + };
732 +
733 + const sealReadyIntent = async (workspaceId, ownerId) => {
734 + const { workspace, workspaceFiles, changedFiles, targetBranch, intent } =
735 + await sealWorkspaceIntent(workspaceId, ownerId);
736 return {
737 text: `✅ <b>آمادهٔ تأیید Commit</b>\n${workspaceFiles ? `Change Set: <b>${changedFiles.length} فایل تغییرکرده</b>\n${changedFiles.map((file) => `• <code>${escapeHtml(file.path)}</code>`).join('\n')}` : `فایل: <code>${escapeHtml(workspace.path)}</code>`}\nBranch: <code>${escapeHtml(targetBranch)}</code>\nBase: <code>${escapeHtml(String(workspace.baseHeadSha).slice(0, 10))}</code>\n\nمرحلهٔ بعد فقط درخواست تأیید امن را می‌سازد؛ تا تأیید معتبر مصرف نشود GitHub WRITE اجرا نمی‌شود.`,
738 reply_markup: {
@@ -729,6 +766,22 @@ export function createWorkspaceController({
766 };
767
768 return {
769 + createWorkspaceFromRef({ ownerId, refId }) {
770 + return createWorkspaceFromRef(refId, ownerFrom({ ownerId }));
771 + },
772 +
773 + addWorkspaceFileFromRef({ ownerId, workspaceId, refId }) {
774 + return addWorkspaceFileFromRef(
775 + refId,
776 + ownerFrom({ ownerId }),
777 + workspaceId
778 + );
779 + },
780 +
781 + sealWorkspaceIntent({ ownerId, workspaceId, review }) {
782 + return sealWorkspaceIntent(workspaceId, ownerFrom({ ownerId }), review);
783 + },
784 +
785 resolveCallback(data, context = {}) {
786 const parsed = parseCallback(data);
787 if (!parsed) return null;
src/studio-api.js new
+597
@@ -0,0 +1,597 @@
1 +import { validateTelegramWebAppInitData } from './core/telegram-webapp-auth.js';
2 +import { readBoundedJson } from './core/bounded-json.js';
3 +import {
4 + WORKSPACE_EDITOR_LIMITS,
5 + buildWorkspaceDiff,
6 + digestText,
7 + normalizeCommitMessage,
8 + validateEditableFile
9 +} from './core/workspace-policy.js';
10 +import { createWorkspaceController } from './plugins/github/workspace.js';
11 +import { RELEASE_VERSION } from './version.js';
12 +
13 +const PREFIX = '/api/v1/studio';
14 +const HANDLE = /^[A-Za-z0-9_-]{10}$/;
15 +const INTENT = /^[A-Za-z0-9_-]{8}$/;
16 +const encoder = new TextEncoder();
17 +
18 +class StudioError extends Error {
19 + constructor(status, message) {
20 + super(message);
21 + this.status = status;
22 + }
23 +}
24 +
25 +const response = (payload, status = 200) =>
26 + Response.json(payload, {
27 + status,
28 + headers: {
29 + 'cache-control': 'no-store',
30 + 'x-content-type-options': 'nosniff'
31 + }
32 + });
33 +
34 +function handle(value) {
35 + if (typeof value !== 'string' || !HANDLE.test(value))
36 + throw new StudioError(400, 'شناسه معتبر نیست.');
37 + return value;
38 +}
39 +
40 +function repositoryId(value) {
41 + if (
42 + !/^[1-9][0-9]*$/.test(String(value ?? '')) ||
43 + !Number.isSafeInteger(Number(value))
44 + )
45 + throw new StudioError(400, 'شناسه مخزن معتبر نیست.');
46 + return String(value);
47 +}
48 +
49 +function filePath(value, { allowRoot = false } = {}) {
50 + if (allowRoot && (value === '' || value === null)) return '';
51 + if (
52 + typeof value !== 'string' ||
53 + value.length > 1024 ||
54 + value.includes('\\') ||
55 + Array.from(value).some((character) => {
56 + const code = character.codePointAt(0);
57 + return code < 32 || code === 127;
58 + }) ||
59 + value.startsWith('/') ||
60 + value.split('/').some((part) => !part || part === '.' || part === '..')
61 + )
62 + throw new StudioError(400, 'مسیر فایل معتبر نیست.');
63 + return value;
64 +}
65 +
66 +async function readBody(
67 + request,
68 + allowedKeys,
69 + maxBytes = 4096,
70 + allowEmpty = false
71 +) {
72 + if (!request.body && allowEmpty) return {};
73 + let body;
74 + try {
75 + body = await readBoundedJson(request, maxBytes);
76 + } catch (error) {
77 + if (error instanceof RangeError)
78 + throw new StudioError(413, 'حجم درخواست بیش از حد مجاز است.');
79 + if (error instanceof SyntaxError)
80 + throw new StudioError(400, 'درخواست JSON معتبر نیست.');
81 + throw error;
82 + }
83 + if (
84 + !body ||
85 + typeof body !== 'object' ||
86 + Array.isArray(body) ||
87 + Object.keys(body).some((key) => !allowedKeys.includes(key))
88 + )
89 + throw new StudioError(400, 'فیلدهای درخواست معتبر نیستند.');
90 + return body;
91 +}
92 +
93 +function filesOf(workspace) {
94 + return Array.isArray(workspace.files) && workspace.files.length
95 + ? workspace.files
96 + : [
97 + {
98 + path: workspace.path,
99 + draftText: workspace.draftText,
100 + originalText: workspace.originalText,
101 + revision: workspace.revision ?? 0
102 + }
103 + ];
104 +}
105 +
106 +function workspaceDto(workspace) {
107 + return {
108 + id: workspace.id,
109 + repoId: String(workspace.repoId),
110 + repoFullName: workspace.repoFullName,
111 + baseBranch: workspace.baseBranch,
112 + baseHeadSha: workspace.baseHeadSha,
113 + state: workspace.state || 'DRAFT',
114 + path: workspace.path,
115 + files: filesOf(workspace).map((file) => ({
116 + path: file.path,
117 + draftText: file.draftText,
118 + revision: file.revision ?? 0
119 + })),
120 + commitMessage: workspace.commitMessage || '',
121 + ...(workspace.commitSha && workspace.branch
122 + ? { result: { commitSha: workspace.commitSha, branch: workspace.branch } }
123 + : {})
124 + };
125 +}
126 +
127 +const workspaceResponse = (workspace) =>
128 + response({
129 + ok: true,
130 + workspace: workspaceDto(workspace),
131 + limits: WORKSPACE_EDITOR_LIMITS
132 + });
133 +
134 +async function requireWorkspace(workspaces, ownerId, workspaceId) {
135 + const workspace = await workspaces.getWorkspace({ ownerId, workspaceId });
136 + if (!workspace)
137 + throw new StudioError(404, 'فضای کار پیدا نشد یا منقضی شده است.');
138 + return workspace;
139 +}
140 +
141 +function assertEditable(workspace) {
142 + if (['COMMITTING', 'COMMITTED'].includes(workspace.state))
143 + throw new StudioError(409, 'این فضای کار اکنون قابل ویرایش نیست.');
144 +}
145 +
146 +function expectedRevision(request) {
147 + const value = request.headers.get('if-match');
148 + if (value === null)
149 + throw new StudioError(428, 'نسخه فایل برای ذخیره الزامی است.');
150 + const match = value.match(/^(?:"(0|[1-9][0-9]*)"|(0|[1-9][0-9]*))$/);
151 + const revision = match ? Number(match[1] ?? match[2]) : NaN;
152 + if (!Number.isSafeInteger(revision))
153 + throw new StudioError(400, 'نسخه فایل معتبر نیست.');
154 + return revision;
155 +}
156 +
157 +function reviewOf(workspace) {
158 + return {
159 + baseHeadSha: workspace.baseHeadSha,
160 + files: filesOf(workspace).map((file) => ({
161 + path: file.path,
162 + revision: file.revision ?? 0
163 + }))
164 + };
165 +}
166 +
167 +function validateReview(review) {
168 + if (
169 + !review ||
170 + typeof review !== 'object' ||
171 + Array.isArray(review) ||
172 + Object.keys(review).some(
173 + (key) => !['baseHeadSha', 'files'].includes(key)
174 + ) ||
175 + typeof review.baseHeadSha !== 'string' ||
176 + !/^[a-f0-9]{40}$/i.test(review.baseHeadSha) ||
177 + !Array.isArray(review.files) ||
178 + !review.files.length ||
179 + review.files.length > WORKSPACE_EDITOR_LIMITS.maxFiles
180 + )
181 + throw new StudioError(400, 'ابتدا Diff فعلی را بازبینی کنید.');
182 + const paths = new Set();
183 + for (const file of review.files) {
184 + if (
185 + !file ||
186 + typeof file !== 'object' ||
187 + Array.isArray(file) ||
188 + Object.keys(file).some((key) => !['path', 'revision'].includes(key)) ||
189 + !Number.isSafeInteger(file.revision) ||
190 + file.revision < 0
191 + )
192 + throw new StudioError(400, 'نسخه بازبینی Diff معتبر نیست.');
193 + filePath(file.path);
194 + if (paths.has(file.path))
195 + throw new StudioError(400, 'نسخه بازبینی Diff معتبر نیست.');
196 + paths.add(file.path);
197 + }
198 + return review;
199 +}
200 +
201 +function assertAggregate(files) {
202 + if (
203 + files.length > WORKSPACE_EDITOR_LIMITS.maxFiles ||
204 + files.reduce(
205 + (total, file) =>
206 + total +
207 + Math.max(
208 + encoder.encode(file.originalText ?? '').byteLength,
209 + encoder.encode(file.draftText ?? '').byteLength
210 + ),
211 + 0
212 + ) > WORKSPACE_EDITOR_LIMITS.maxAggregateBytes
213 + )
214 + throw new StudioError(
215 + 422,
216 + 'حجم یا تعداد فایل‌های فضای کار بیش از حد مجاز است.'
217 + );
218 +}
219 +
220 +async function provider(operation) {
221 + try {
222 + return await operation();
223 + } catch {
224 + throw new StudioError(
225 + 502,
226 + 'ارتباط با سرویس مخزن برقرار نشد. دوباره تلاش کنید.'
227 + );
228 + }
229 +}
230 +
231 +function controllerError(error) {
232 + if (error instanceof StudioError) return error;
233 + if (error?.code === 'REVISION_CONFLICT') return error;
234 + if (error?.code === 'WORKSPACE_NOT_EDITABLE')
235 + return new StudioError(409, 'این فضای کار اکنون قابل ویرایش نیست.');
236 + if (error?.code === 'WORKSPACE_LIMIT_EXCEEDED')
237 + return new StudioError(
238 + 422,
239 + 'حجم یا تعداد فایل‌های فضای کار بیش از حد مجاز است.'
240 + );
241 + const message = String(error?.message || '');
242 + if (/reference.*(?:missing|expired)|not found or expired/i.test(message))
243 + return new StudioError(404, 'مرجع یا فضای کار پیدا نشد یا منقضی شده است.');
244 + if (/repository mismatch|reference mismatch|already exists/i.test(message))
245 + return new StudioError(400, 'مرجع فایل با فضای کار مطابقت ندارد.');
246 + if (/limited|not editable|binary|LFS|sensitive|aggregate size/i.test(message))
247 + return new StudioError(422, 'این فایل یا اندازه آن برای ویرایش مجاز نیست.');
248 + if (/No draft change|Commit message.*(?:required|120)/i.test(message))
249 + return new StudioError(422, 'تغییر فایل و پیام Commit معتبر الزامی است.');
250 + return new StudioError(502, 'عملیات فضای کار انجام نشد. دوباره تلاش کنید.');
251 +}
252 +
253 +async function controllerOperation(operation) {
254 + try {
255 + return await operation();
256 + } catch (error) {
257 + throw controllerError(error);
258 + }
259 +}
260 +
261 +async function requestApproval({
262 + ownerId,
263 + workspaceId,
264 + review,
265 + controller,
266 + bot
267 +}) {
268 + if (
269 + !bot?.router?.dispatchCallback ||
270 + !bot.approvals?.isReplayProtected?.() ||
271 + !bot.telegram?.sendMessage
272 + )
273 + throw new StudioError(503, 'تأیید امن در دسترس نیست.');
274 + const { workspace, intent } = await controllerOperation(() =>
275 + controller.sealWorkspaceIntent({ ownerId, workspaceId, review })
276 + );
277 + if (
278 + !intent ||
279 + !INTENT.test(String(intent.id || '')) ||
280 + intent.workspaceId !== workspaceId ||
281 + intent.state !== 'READY' ||
282 + Number(intent.repoId) !== Number(workspace.repoId)
283 + )
284 + throw new StudioError(409, 'فضای کار برای تأیید آماده نیست.');
285 + const routed = await bot.router.dispatchCallback(
286 + `wscommit:${workspace.repoId}:${intent.id}`,
287 + { isOwner: true, ownerId }
288 + );
289 + if (
290 + routed?.requiresApproval !== true ||
291 + routed.pluginId !== 'github' ||
292 + routed.actionId !== 'github.workspace.commit_branch' ||
293 + routed.risk !== 'WRITE' ||
294 + Number(routed.approval?.input?.repoId) !== Number(workspace.repoId) ||
295 + routed.approval?.input?.intentId !== intent.id
296 + )
297 + throw new StudioError(503, 'درخواست تأیید امن پذیرفته نشد.');
298 + const token = await bot.approvals.issue({
299 + pluginId: routed.pluginId,
300 + actionId: routed.actionId,
301 + risk: routed.risk,
302 + ownerId,
303 + input: routed.approval.input
304 + });
305 + const approval = await bot.approvals.verify(token, {
306 + ownerId,
307 + pluginId: 'github',
308 + actionId: 'github.workspace.commit_branch',
309 + risk: 'WRITE'
310 + });
311 + await bot.telegram.sendMessage(
312 + ownerId,
313 + `⚠️ تأیید نهایی Commit روی شاخه جدید لازم است.\nBranch: <code>${intent.targetBranch}</code>\nBase: <code>${intent.baseHeadSha}</code>\n\nاین تأیید فقط برای نسخه بررسی‌شده و یک‌بار معتبر است.`,
314 + {
315 + inline_keyboard: [
316 + [{ text: '✅ تأیید و Commit', callback_data: `approve:${token}` }],
317 + [{ text: '↩️ انصراف', callback_data: `repo:${workspace.repoId}` }]
318 + ]
319 + }
320 + );
321 + return response({
322 + ok: true,
323 + approvalRequested: true,
324 + workspaceId,
325 + targetBranch: intent.targetBranch,
326 + baseHeadSha: intent.baseHeadSha,
327 + expiresAt: approval.expiresAt
328 + });
329 +}
330 +
331 +export async function handleStudioApiRequest(
332 + request,
333 + { env = {}, github, workspaces, bot, now = () => Date.now() } = {}
334 +) {
335 + const url = new URL(request.url);
336 + if (url.pathname !== PREFIX && !url.pathname.startsWith(`${PREFIX}/`))
337 + return null;
338 + try {
339 + const ownerId = String(env.OWNER_TELEGRAM_ID || '');
340 + if (
341 + !/^[1-9][0-9]*$/.test(ownerId) ||
342 + !Number.isSafeInteger(Number(ownerId)) ||
343 + !env.TELEGRAM_BOT_TOKEN
344 + )
345 + throw new StudioError(503, 'پیکربندی ورود امن کامل نیست.');
346 + let identity;
347 + try {
348 + const initData = request.headers.get('x-telegram-init-data') || '';
349 + if (initData.length > 8192) throw new Error('Invalid initData');
350 + identity = await validateTelegramWebAppInitData(initData, {
351 + botToken: env.TELEGRAM_BOT_TOKEN,
352 + ownerId,
353 + now,
354 + maxAgeSeconds: 3600
355 + });
356 + } catch {
357 + throw new StudioError(
358 + 403,
359 + 'این برنامه را از حساب مالک در تلگرام باز کنید.'
360 + );
361 + }
362 +
363 + const route = url.pathname.slice(PREFIX.length);
364 + if (request.method === 'GET' && route === '')
365 + return response({
366 + ok: true,
367 + user: {
368 + name: String(
369 + identity.user.first_name || identity.user.username || 'مالک'
370 + )
371 + },
372 + limits: WORKSPACE_EDITOR_LIMITS,
373 + version: RELEASE_VERSION
374 + });
375 + if (request.method === 'GET' && route === '/repos') {
376 + const repositories = await provider(() => github.listRepositories());
377 + return response({
378 + ok: true,
379 + repositories: repositories.map((repo) => ({
380 + id: String(repo.id),
381 + name: repo.name,
382 + fullName: repo.fullName,
383 + defaultBranch: repo.defaultBranch,
384 + private: Boolean(repo.private),
385 + ...(repo.description ? { description: repo.description } : {})
386 + }))
387 + });
388 + }
389 + if (!github || !workspaces)
390 + throw new StudioError(503, 'سرویس فضای کار در دسترس نیست.');
391 + const controller = createWorkspaceController({ github, workspaces });
392 + if (request.method === 'GET' && route === '/tree') {
393 + const repoId = repositoryId(url.searchParams.get('repoId'));
394 + const path = filePath(url.searchParams.get('path'), { allowRoot: true });
395 + const workspaceId = url.searchParams.get('workspaceId');
396 + let workspace;
397 + if (workspaceId !== null) {
398 + workspace = await requireWorkspace(
399 + workspaces,
400 + ownerId,
401 + handle(workspaceId)
402 + );
403 + if (String(workspace.repoId) !== repoId)
404 + throw new StudioError(400, 'مخزن با فضای کار مطابقت ندارد.');
405 + }
406 + const [repository, items] = await provider(() =>
407 + Promise.all([
408 + github.getRepository(repoId),
409 + github.listFiles(
410 + repoId,
411 + path,
412 + workspace ? { ref: workspace.baseHeadSha } : {}
413 + )
414 + ])
415 + );
416 + const refs = await workspaces.createNavigationRefs({
417 + ownerId,
418 + refs: items.map((item) => ({
419 + repoId: Number(repoId),
420 + path: item.path,
421 + sha: item.sha,
422 + type: workspace && item.type === 'file' ? 'workspace-add' : item.type,
423 + ...(workspace && item.type === 'file'
424 + ? { workspaceId: workspace.id }
425 + : {})
426 + }))
427 + });
428 + return response({
429 + ok: true,
430 + repository: {
431 + id: String(repository.id),
432 + fullName: repository.fullName,
433 + defaultBranch: repository.defaultBranch
434 + },
435 + path,
436 + items: items.map((item, i) => ({
437 + refId: refs[i].refId,
438 + name: item.name,
439 + path: item.path,
440 + type: item.type,
441 + size: item.size ?? 0
442 + }))
443 + });
444 + }
445 + if (request.method === 'POST' && route === '/workspaces') {
446 + const body = await readBody(request, ['refId']);
447 + const workspace = await controllerOperation(() =>
448 + controller.createWorkspaceFromRef({
449 + ownerId,
450 + refId: handle(body.refId)
451 + })
452 + );
453 + return workspaceResponse(workspace);
454 + }
455 + const match = route.match(
456 + /^\/workspaces\/([^/]+)(?:\/(files|diff|message|approval))?$/
457 + );
458 + if (!match) throw new StudioError(404, 'مسیر پیدا نشد.');
459 + const workspaceId = handle(match[1]);
460 + const action = match[2] || '';
461 + const workspace = await requireWorkspace(workspaces, ownerId, workspaceId);
462 + if (request.method === 'GET' && action === '')
463 + return workspaceResponse(workspace);
464 + if (request.method === 'GET' && action === 'diff')
465 + return response({
466 + ok: true,
467 + diff: buildWorkspaceDiff({
468 + files: filesOf(workspace),
469 + maxChars: 10000
470 + }),
471 + review: reviewOf(workspace)
472 + });
473 + if (request.method === 'DELETE' && action === '') {
474 + await workspaces.cancelWorkspace({ ownerId, workspaceId });
475 + return response({ ok: true, cancelled: true, workspaceId });
476 + }
477 + assertEditable(workspace);
478 + if (request.method === 'PUT' && action === 'files') {
479 + const revision = expectedRevision(request);
480 + const body = await readBody(
481 + request,
482 + ['path', 'text'],
483 + WORKSPACE_EDITOR_LIMITS.maxBytes + 4096
484 + );
485 + const path = filePath(body.path);
486 + const files = filesOf(workspace);
487 + const selected = files.find((file) => file.path === path);
488 + if (!selected || typeof body.text !== 'string')
489 + throw new StudioError(400, 'فایل یا متن درخواست معتبر نیست.');
490 + const policy = validateEditableFile({ path, text: body.text });
491 + if (!policy.editable)
492 + throw new StudioError(
493 + 422,
494 + 'متن فایل برای ویرایش مجاز نیست یا بیش از حد مجاز است.'
495 + );
496 + assertAggregate(
497 + files.map((file) =>
498 + file.path === path ? { ...file, draftText: policy.text } : file
499 + )
500 + );
501 + const updated = await workspaces.updateWorkspaceFileDraft({
502 + ownerId,
503 + workspaceId,
504 + path,
505 + text: policy.text,
506 + digest: await digestText(policy.text),
507 + expectedRevision: revision
508 + });
509 + return workspaceResponse(updated);
510 + }
511 + if (request.method === 'POST' && action === 'files') {
512 + const body = await readBody(request, ['refId']);
513 + const updated = await controllerOperation(() =>
514 + controller.addWorkspaceFileFromRef({
515 + ownerId,
516 + workspaceId,
517 + refId: handle(body.refId)
518 + })
519 + );
520 + return workspaceResponse(updated);
521 + }
522 + if (request.method === 'PUT' && action === 'message') {
523 + const body = await readBody(request, ['message']);
524 + if (typeof body.message !== 'string')
525 + throw new StudioError(400, 'پیام Commit معتبر نیست.');
526 + const message = await controllerOperation(() =>
527 + normalizeCommitMessage(body.message)
528 + );
529 + return workspaceResponse(
530 + await workspaces.setCommitMessage({
531 + ownerId,
532 + workspaceId,
533 + message,
534 + digest: await digestText(message)
535 + })
536 + );
537 + }
538 + if (request.method === 'POST' && action === 'approval') {
539 + const body = await readBody(request, ['review', 'message'], 12288);
540 + const review = validateReview(body.review);
541 + if (typeof body.message !== 'string')
542 + throw new StudioError(400, 'پیام Commit معتبر نیست.');
543 + const message = await controllerOperation(() =>
544 + normalizeCommitMessage(body.message)
545 + );
546 + const expectedReview = {
547 + ...review,
548 + commitMessageDigest: await digestText(message)
549 + };
550 + return await requestApproval({
551 + ownerId,
552 + workspaceId,
553 + review: expectedReview,
554 + controller,
555 + bot
556 + });
557 + }
558 + throw new StudioError(405, 'روش درخواست مجاز نیست.');
559 + } catch (error) {
560 + if (error instanceof StudioError)
561 + return response({ ok: false, error: error.message }, error.status);
562 + if (error?.code === 'WORKSPACE_NOT_EDITABLE')
563 + return response(
564 + { ok: false, error: 'این فضای کار اکنون قابل ویرایش نیست.' },
565 + 409
566 + );
567 + if (error?.code === 'REVISION_CONFLICT' || error?.status === 409)
568 + return response(
569 + {
570 + ok: false,
571 + error: 'نسخه فایل تغییر کرده است. آخرین نسخه را باز کنید.'
572 + },
573 + 409
574 + );
575 + if (error?.code === 'DIFF_COMPLEXITY_LIMIT')
576 + return response(
577 + {
578 + ok: false,
579 + error:
580 + 'تغییرات برای محاسبه امن Diff پیچیده‌اند؛ تغییرها را کوچک‌تر کنید.'
581 + },
582 + 422
583 + );
584 + if (error?.code === 'WORKSPACE_LIMIT_EXCEEDED')
585 + return response(
586 + {
587 + ok: false,
588 + error: 'حجم یا تعداد فایل‌های فضای کار بیش از حد مجاز است.'
589 + },
590 + 422
591 + );
592 + return response(
593 + { ok: false, error: 'عملیات انجام نشد. دوباره تلاش کنید.' },
594 + 502
595 + );
596 + }
597 +}
src/studio-assets.js new
+61
@@ -0,0 +1,61 @@
1 +const unavailable = () =>
2 + new Response('Nexa Studio موقتاً در دسترس نیست؛ دوباره تلاش کنید.', {
3 + status: 503,
4 + headers: {
5 + 'content-type': 'text/plain; charset=utf-8',
6 + 'cache-control': 'no-store'
7 + }
8 + });
9 +
10 +export async function handleStudioAssetsRequest(request, env = {}) {
11 + const url = new URL(request.url);
12 + if (url.pathname !== '/studio' && !url.pathname.startsWith('/studio/'))
13 + return null;
14 + if (!['GET', 'HEAD'].includes(request.method))
15 + return new Response('Method Not Allowed', {
16 + status: 405,
17 + headers: { allow: 'GET, HEAD' }
18 + });
19 + if (url.pathname === '/studio')
20 + return new Response(null, {
21 + status: 308,
22 + headers: { location: '/studio/', 'cache-control': 'no-store' }
23 + });
24 + if (!env.ASSETS?.fetch) return unavailable();
25 + try {
26 + const response = await env.ASSETS.fetch(
27 + request.method === 'HEAD'
28 + ? new Request(request, { method: 'GET' })
29 + : request
30 + );
31 + const headers = new Headers(response.headers);
32 + headers.set('x-content-type-options', 'nosniff');
33 + headers.set('referrer-policy', 'no-referrer');
34 + if (url.pathname === '/studio/' || url.pathname === '/studio/index.html') {
35 + if (!response.ok) return unavailable();
36 + const html = await response.text();
37 + if (!html.includes('__NEXA_NONCE__')) return unavailable();
38 + const nonce = crypto.randomUUID().replaceAll('-', '');
39 + headers.set('content-type', 'text/html; charset=utf-8');
40 + headers.set('cache-control', 'no-store');
41 + headers.delete('etag');
42 + headers.delete('content-length');
43 + headers.set(
44 + 'content-security-policy',
45 + `default-src 'none'; script-src 'self' https://telegram.org; style-src 'self' 'nonce-${nonce}'; connect-src 'self'; img-src 'self' data:; font-src 'self'; object-src 'none'; base-uri 'none'; form-action 'none'`
46 + );
47 + return new Response(
48 + request.method === 'HEAD'
49 + ? null
50 + : html.replaceAll('__NEXA_NONCE__', nonce),
51 + { status: 200, headers }
52 + );
53 + }
54 + return new Response(request.method === 'HEAD' ? null : response.body, {
55 + status: response.status,
56 + headers
57 + });
58 + } catch {
59 + return unavailable();
60 + }
61 +}
src/telegram.js
+7
@@ -111,6 +111,13 @@ export class TelegramClient {
111 });
112 }
113
114 + async setChatMenuButton(chatId, menuButton) {
115 + return this.callApi('setChatMenuButton', {
116 + chat_id: chatId,
117 + menu_button: menuButton
118 + });
119 + }
120 +
121 async editMessageText(
122 chatId,
123 messageId,
test/bot.test.js
+25 -8
@@ -1,6 +1,7 @@
1 import { describe, it } from 'node:test';
2 import assert from 'node:assert/strict';
3 import { NexaDevBot } from '../src/bot.js';
4 +import { GuidedNexaDevBot } from '../src/guide-bot.js';
5
6 const fakeGitHub = {
7 owner: 'davoodmehraban89',
@@ -68,28 +69,44 @@ describe('Nexa Dev Bot - Cloudflare plugin registration', () => {
69 });
70
71 describe('Nexa Dev Bot - Webhook Dispatcher & In-Place Editing', () => {
71 - it('/start installs the bottom quick menu and sends the inline Main Menu', async () => {
72 + it('/start on the deployed guided bot clears the old keyboard and opens Studio', async () => {
73 const sentMessages = [];
73 - const bot = makeBot();
74 + const bot = new GuidedNexaDevBot({ OWNER_TELEGRAM_ID: '123456' });
75 bot.telegram.sendMessage = async (chatId, text, replyMarkup) => {
76 sentMessages.push({ chatId, text, replyMarkup });
77 return { ok: true, result: { message_id: 500 + sentMessages.length } };
78 };
79 + bot.telegram.setChatMenuButton = async () => ({ ok: true });
80
81 const res = await bot.handleUpdate({
80 - message: { message_id: 100, chat: { id: 123456 }, text: '/start' }
82 + message: {
83 + message_id: 100,
84 + from: { id: 123456 },
85 + chat: { id: 123456, type: 'private' },
86 + text: '/start'
87 + }
88 });
89
90 assert.equal(res.ok, true);
91 assert.equal(res.command, 'start');
85 - assert.equal(res.persistentMenu, true);
92 + assert.equal(res.studioEntry, true);
93 assert.equal(sentMessages.length, 2);
94 assert.equal(sentMessages[0].chatId, 123456);
88 - assert.equal(sentMessages[0].replyMarkup.is_persistent, true);
89 - assert.ok(sentMessages[0].replyMarkup.keyboard);
95 + assert.deepEqual(sentMessages[0].replyMarkup, { remove_keyboard: true });
96 assert.equal(sentMessages[1].chatId, 123456);
91 - assert.match(sentMessages[1].text, /Nexa Dev Bot/);
92 - assert.ok(sentMessages[1].replyMarkup.inline_keyboard);
97 + assert.match(sentMessages[1].text, /Nexa Studio/);
98 + assert.deepEqual(sentMessages[1].replyMarkup, {
99 + inline_keyboard: [
100 + [
101 + {
102 + text: 'باز کردن Nexa Studio',
103 + web_app: {
104 + url: 'https://nexa-dev-bot.davoodmehraban89.workers.dev/studio/'
105 + }
106 + }
107 + ]
108 + ]
109 + });
110 });
111
112 it('/repos is dispatched through the plugin router', async () => {
test/help-guide.test.js
+17 -7
@@ -215,23 +215,33 @@ describe('Nexa Dev Bot - in-app V2.1 guide', () => {
215 }
216 });
217
218 - it('keeps Guide in the persistent bottom keyboard and routes its text without consuming workspace input', async () => {
219 - const bot = new GuidedNexaDevBot({});
218 + it('opens Studio from start while preserving old Guide text navigation', async () => {
219 + const bot = new GuidedNexaDevBot({ OWNER_TELEGRAM_ID: '1' });
220 const sent = [];
221 bot.telegram.sendMessage = async (chatId, text, replyMarkup) => {
222 sent.push({ chatId, text, replyMarkup });
223 return { ok: true };
224 };
225 + bot.telegram.setChatMenuButton = async () => ({ ok: true });
226
227 await bot.handleMessage({
227 - chat: { id: 1 },
228 + chat: { id: 1, type: 'private' },
229 from: { id: 1 },
230 text: '/start'
231 });
231 - const quickKeyboard = sent[0].replyMarkup.keyboard
232 - .flat()
233 - .map((button) => button.text);
234 - assert.ok(quickKeyboard.includes('📘 راهنما'));
232 + assert.deepEqual(sent[0].replyMarkup, { remove_keyboard: true });
233 + assert.deepEqual(sent[1].replyMarkup, {
234 + inline_keyboard: [
235 + [
236 + {
237 + text: 'باز کردن Nexa Studio',
238 + web_app: {
239 + url: 'https://nexa-dev-bot.davoodmehraban89.workers.dev/studio/'
240 + }
241 + }
242 + ]
243 + ]
244 + });
245
246 sent.length = 0;
247 await bot.handleMessage({
test/index.test.js
+3 -1
@@ -18,7 +18,7 @@ const startUpdate = {
18 message: {
19 message_id: 202,
20 from: { id: 123 },
21 - chat: { id: 123 },
21 + chat: { id: 123, type: 'private' },
22 text: '/start'
23 }
24 };
@@ -100,6 +100,8 @@ describe('Nexa Dev Bot - Cloudflare Worker Entrypoint', () => {
100 const body = await res.json();
101 assert.equal(body.ok, true);
102 assert.equal(body.command, 'start');
103 + assert.equal(body.studioEntry, true);
104 + assert.equal(body.menuButtonConfigured, true);
105 } finally {
106 globalThis.fetch = originalFetch;
107 }
test/navigation.test.js
+15 -7
@@ -196,14 +196,14 @@ async function sendUpdate(update) {
196 return response.json();
197 }
198
199 -test('persistent quick menu bootstrap keeps later inline navigation on one Telegram message', async () => {
199 +test('Studio-first bootstrap keeps legacy inline navigation on one Telegram message', async () => {
200 const mock = installApiMock();
201 try {
202 await sendUpdate({
203 message: {
204 message_id: 1,
205 from: { id: 123 },
206 - chat: { id: 123 },
206 + chat: { id: 123, type: 'private' },
207 text: '/start'
208 }
209 });
@@ -211,11 +211,19 @@ test('persistent quick menu bootstrap keeps later inline navigation on one Teleg
211 (call) => call.method === 'sendMessage'
212 );
213 assert.equal(startSends.length, 2);
214 - assert.equal(startSends[0].body.reply_markup.is_persistent, true);
215 - assert.ok(startSends[0].body.reply_markup.keyboard);
216 - assert.match(startSends[1].body.text, /Nexa Dev Bot/);
214 + assert.equal(startSends[0].body.reply_markup.remove_keyboard, true);
215 + assert.match(startSends[1].body.text, /Nexa Studio/);
216 + assert.equal(
217 + startSends[1].body.reply_markup.inline_keyboard[0][0].web_app.url,
218 + 'https://example.test/studio/'
219 + );
220 + assert.equal(
221 + mock.telegramCalls.filter((call) => call.method === 'setChatMenuButton')
222 + .length,
223 + 1
224 + );
225
218 - const message = { message_id: 700, chat: { id: 123 } };
226 + const message = { message_id: 700, chat: { id: 123, type: 'private' } };
227 for (const data of ['menu:repos', 'repo:1001', 'menu:repos', 'menu:main']) {
228 await sendUpdate({
229 callback_query: { id: data, from: { id: 123 }, data, message }
@@ -228,7 +236,7 @@ test('persistent quick menu bootstrap keeps later inline navigation on one Teleg
236 assert.ok(edits.every((call) => call.body.message_id === 700));
237 assert.match(edits[0].body.text, /فهرست مخزن‌ها/);
238 assert.match(edits[1].body.text, /پروژه: demo/);
231 - assert.match(edits[3].body.text, /Nexa Dev Bot/);
239 + assert.match(edits[3].body.text, /Nexa Studio/);
240 assert.equal(
241 mock.telegramCalls.filter((call) => call.method === 'sendMessage').length,
242 2,
test/studio-api.test.js new
+930
@@ -0,0 +1,930 @@
1 +import test from 'node:test';
2 +import assert from 'node:assert/strict';
3 +import { DurableWorkspaceStoreClient } from '../src/core/workspace-store.js';
4 +import { WorkspaceStore } from '../src/durable/workspace-store.js';
5 +import { KillSwitchGuidedNexaDevBot } from '../src/kill-switch-bot.js';
6 +import { GitHubService } from '../src/github.js';
7 +import {
8 + createWorkspaceController,
9 + commitWorkspaceIntent
10 +} from '../src/plugins/github/workspace.js';
11 +import {
12 + WORKSPACE_EDITOR_LIMITS,
13 + digestText
14 +} from '../src/core/workspace-policy.js';
15 +import {
16 + makeReplayState,
17 + makeReplayNamespace
18 +} from './helpers/replay-namespace.js';
19 +
20 +const api = await import('../src/studio-api.js').catch(() => ({}));
21 +const BOT_TOKEN = '123456:studio-test-token';
22 +const OWNER = '42';
23 +const NOW = Date.parse('2026-10-26T12:00:00Z');
24 +const HEAD = 'a'.repeat(40);
25 +const TREE = 'b'.repeat(40);
26 +const BLOB = 'c'.repeat(40);
27 +
28 +async function signedInitData({ userId = 42, age = 0 } = {}) {
29 + const fields = new URLSearchParams({
30 + auth_date: String(Math.floor(NOW / 1000) - age),
31 + user: JSON.stringify({ id: userId, first_name: 'Owner' })
32 + });
33 + const encode = (value) => new TextEncoder().encode(value);
34 + const sign = async (keyBytes, value) => {
35 + const key = await crypto.subtle.importKey(
36 + 'raw',
37 + keyBytes,
38 + { name: 'HMAC', hash: 'SHA-256' },
39 + false,
40 + ['sign']
41 + );
42 + return new Uint8Array(await crypto.subtle.sign('HMAC', key, encode(value)));
43 + };
44 + const check = [...fields.entries()]
45 + .sort(([a], [b]) => a.localeCompare(b))
46 + .map(([key, value]) => `${key}=${value}`)
47 + .join('\n');
48 + const signature = await sign(
49 + await sign(encode('WebAppData'), BOT_TOKEN),
50 + check
51 + );
52 + fields.set(
53 + 'hash',
54 + [...signature].map((byte) => byte.toString(16).padStart(2, '0')).join('')
55 + );
56 + return fields.toString();
57 +}
58 +
59 +function fixture() {
60 + let currentTime = NOW;
61 + const states = new Map();
62 + const namespace = {
63 + idFromName: (id) => String(id),
64 + get(id) {
65 + if (!states.has(id)) states.set(id, makeReplayState());
66 + return {
67 + fetch: (request) => new WorkspaceStore(states.get(id)).fetch(request)
68 + };
69 + }
70 + };
71 + const workspaces = new DurableWorkspaceStoreClient({
72 + namespace,
73 + now: () => currentTime
74 + });
75 + const calls = [];
76 + const repository = {
77 + id: '123',
78 + name: 'repo',
79 + fullName: 'owner/repo',
80 + defaultBranch: 'main',
81 + private: true
82 + };
83 + const github = {
84 + async listRepositories() {
85 + calls.push('repos');
86 + return [repository];
87 + },
88 + async getRepository(repoId) {
89 + calls.push('repo');
90 + return { ...repository, id: String(repoId) };
91 + },
92 + async listFiles(repoId, path, options) {
93 + calls.push(['tree', repoId, path, options]);
94 + return Array.from({ length: 35 }, (_, i) => ({
95 + name: `file-${i}.js`,
96 + path: path ? `${path}/file-${i}.js` : `file-${i}.js`,
97 + type: 'file',
98 + size: 7,
99 + sha: BLOB
100 + }));
101 + },
102 + async getBranchSnapshot() {
103 + calls.push('snapshot');
104 + return { headSha: HEAD, treeSha: TREE };
105 + },
106 + async getFileAtRef(repoId, path, ref) {
107 + calls.push(['file', repoId, path, ref]);
108 + return { path, content: 'before\n', size: 7, sha: BLOB };
109 + },
110 + async createGitBlob() {
111 + throw new Error('Unexpected provider write');
112 + },
113 + async createGitTree() {
114 + throw new Error('Unexpected provider write');
115 + },
116 + async createGitCommit() {
117 + throw new Error('Unexpected provider write');
118 + },
119 + async createGitRef() {
120 + throw new Error('Unexpected provider write');
121 + }
122 + };
123 + const env = {
124 + TELEGRAM_BOT_TOKEN: BOT_TOKEN,
125 + OWNER_TELEGRAM_ID: OWNER,
126 + APPROVAL_SIGNING_SECRET: 'studio-approval-test-secret',
127 + WORKSPACE_STORE: namespace,
128 + APPROVAL_REPLAY_GUARD: makeReplayNamespace()
129 + };
130 + const bot = new KillSwitchGuidedNexaDevBot(env);
131 + Object.assign(bot.github, github);
132 + bot.approvals.now = () => currentTime;
133 + bot.audit.sink = () => {};
134 + const messages = [];
135 + bot.telegram.sendMessage = async (...args) => {
136 + messages.push(args);
137 + return { ok: true };
138 + };
139 + return {
140 + env,
141 + github,
142 + workspaces,
143 + bot,
144 + calls,
145 + messages,
146 + states,
147 + now: () => currentTime,
148 + advance: (ms) => {
149 + currentTime += ms;
150 + }
151 + };
152 +}
153 +
154 +async function request(
155 + f,
156 + path = '',
157 + { method = 'GET', body, headers = {}, auth = {} } = {}
158 +) {
159 + assert.equal(
160 + typeof api.handleStudioApiRequest,
161 + 'function',
162 + 'Studio API handler exists'
163 + );
164 + return api.handleStudioApiRequest(
165 + new Request(`https://studio.test/api/v1/studio${path}`, {
166 + method,
167 + headers: {
168 + 'x-telegram-init-data': await signedInitData(auth),
169 + ...headers
170 + },
171 + ...(body !== undefined
172 + ? { body: typeof body === 'string' ? body : JSON.stringify(body) }
173 + : {})
174 + }),
175 + f
176 + );
177 +}
178 +
179 +async function create(f) {
180 + const tree = await (await request(f, '/tree?repoId=123')).json();
181 + const response = await request(f, '/workspaces', {
182 + method: 'POST',
183 + body: { refId: tree.items[0].refId }
184 + });
185 + assert.equal(response.status, 200);
186 + return (await response.json()).workspace;
187 +}
188 +
189 +test('Studio authenticates signed, fresh owner initData before touching providers or durable objects on every route', async () => {
190 + const routes = [
191 + ['', 'GET'],
192 + ['/repos', 'GET'],
193 + ['/tree?repoId=123', 'GET'],
194 + ['/workspaces', 'POST'],
195 + ['/workspaces/W123456789', 'GET'],
196 + ['/workspaces/W123456789/files', 'PUT'],
197 + ['/workspaces/W123456789/files', 'POST'],
198 + ['/workspaces/W123456789/diff', 'GET'],
199 + ['/workspaces/W123456789/message', 'PUT'],
200 + ['/workspaces/W123456789/approval', 'POST'],
201 + ['/workspaces/W123456789', 'DELETE']
202 + ];
203 + for (const auth of [{ userId: 99 }, { age: 3601 }]) {
204 + for (const [path, method] of routes) {
205 + const f = fixture();
206 + const response = await request(f, path, {
207 + method,
208 + auth,
209 + body: method === 'GET' ? undefined : {}
210 + });
211 + assert.equal(response.status, 403, `${method} ${path}`);
212 + assert.deepEqual(f.calls, []);
213 + assert.equal(f.states.size, 0);
214 + assert.equal(f.messages.length, 0);
215 + }
216 + }
217 + const f = fixture();
218 + const missing = await request(f, '/repos', {
219 + headers: { 'x-telegram-init-data': '' }
220 + });
221 + assert.equal(missing.status, 403);
222 + assert.deepEqual(f.calls, []);
223 +});
224 +
225 +test('Studio bootstrap, complete repository listing and directory refs expose only structured owner-scoped data', async () => {
226 + const f = fixture();
227 + const bootstrap = await (await request(f)).json();
228 + assert.equal(bootstrap.ok, true);
229 + assert.equal(bootstrap.user.name, 'Owner');
230 + assert.deepEqual(bootstrap.limits, WORKSPACE_EDITOR_LIMITS);
231 + assert.equal(typeof bootstrap.version, 'string');
232 + const repositories = await (await request(f, '/repos')).json();
233 + assert.equal(repositories.repositories[0].fullName, 'owner/repo');
234 + const tree = await (await request(f, '/tree?repoId=123&path=src')).json();
235 + assert.equal(tree.items.length, 35);
236 + assert.equal(tree.path, 'src');
237 + assert.equal(tree.repository.id, '123');
238 + assert.match(tree.items[34].refId, /^[A-Za-z0-9_-]{10}$/);
239 + assert.deepEqual(
240 + await f.workspaces.resolveNavigationRef({
241 + ownerId: '99',
242 + refId: tree.items[0].refId
243 + }),
244 + null
245 + );
246 +});
247 +
248 +test('Studio creates pinned workspaces and refuses expired or foreign refs without provider reads', async () => {
249 + const f = fixture();
250 + const workspace = await create(f);
251 + assert.equal(workspace.baseHeadSha, HEAD);
252 + assert.equal(workspace.files[0].draftText, 'before\n');
253 + assert.equal(workspace.files[0].revision, 0);
254 + assert.equal(Object.hasOwn(workspace.files[0], 'originalText'), false);
255 + assert.equal(Object.hasOwn(workspace, 'originalText'), false);
256 + const foreign = await f.workspaces.createNavigationRefs({
257 + ownerId: '99',
258 + refs: [{ repoId: 123, path: 'secret.js', type: 'file' }]
259 + });
260 + f.calls.length = 0;
261 + const denied = await request(f, '/workspaces', {
262 + method: 'POST',
263 + body: { refId: foreign[0].refId }
264 + });
265 + assert.equal(denied.status, 404);
266 + assert.deepEqual(f.calls, []);
267 + const [ref] = await f.workspaces.createNavigationRefs({
268 + ownerId: OWNER,
269 + ttlMs: 1,
270 + refs: [{ repoId: 123, path: 'old.js', type: 'file' }]
271 + });
272 + f.advance(2);
273 + assert.equal(
274 + (
275 + await request(f, '/workspaces', {
276 + method: 'POST',
277 + body: { refId: ref.refId }
278 + })
279 + ).status,
280 + 404
281 + );
282 + assert.deepEqual(f.calls, []);
283 +});
284 +
285 +test('Studio enforces If-Match, membership, edit policy, diff, normalized messages and immediate deletion', async () => {
286 + const f = fixture();
287 + const workspace = await create(f);
288 + const base = `/workspaces/${workspace.id}`;
289 + assert.equal(
290 + (
291 + await request(f, `${base}/files`, {
292 + method: 'PUT',
293 + body: { path: workspace.path, text: 'after\n' }
294 + })
295 + ).status,
296 + 428
297 + );
298 + assert.equal(
299 + (
300 + await request(f, `${base}/files`, {
301 + method: 'PUT',
302 + headers: { 'If-Match': '0' },
303 + body: { path: 'missing.js', text: 'after\n' }
304 + })
305 + ).status,
306 + 400
307 + );
308 + const update = await request(f, `${base}/files`, {
309 + method: 'PUT',
310 + headers: { 'If-Match': '"0"' },
311 + body: { path: workspace.path, text: 'after\n' }
312 + });
313 + assert.equal(update.status, 200);
314 + assert.equal((await update.json()).workspace.files[0].revision, 1);
315 + assert.equal(
316 + (
317 + await request(f, `${base}/files`, {
318 + method: 'PUT',
319 + headers: { 'If-Match': '0' },
320 + body: { path: workspace.path, text: 'stale\n' }
321 + })
322 + ).status,
323 + 409
324 + );
325 + assert.equal(
326 + (
327 + await request(f, `${base}/files`, {
328 + method: 'PUT',
329 + headers: { 'If-Match': '1' },
330 + body: { path: workspace.path, text: 'x'.repeat(20001) }
331 + })
332 + ).status,
333 + 422
334 + );
335 + const diff = await (await request(f, `${base}/diff`)).json();
336 + assert.equal(diff.ok, true);
337 + assert.match(JSON.stringify(diff.diff), /after/);
338 + const message = await (
339 + await request(f, `${base}/message`, {
340 + method: 'PUT',
341 + body: { message: ' edit\n file ' }
342 + })
343 + ).json();
344 + assert.equal(message.workspace.commitMessage, 'edit file');
345 + assert.equal((await request(f, `/workspaces/W123456789`)).status, 404);
346 + assert.equal((await request(f, base, { method: 'DELETE' })).status, 200);
347 + assert.equal((await request(f, base)).status, 404);
348 +});
349 +
350 +test('Studio workspace file refs are scoped to the same workspace and pinned repository', async () => {
351 + const f = fixture();
352 + const first = await create(f);
353 + const second = await create(f);
354 + f.calls.length = 0;
355 + assert.equal(
356 + (await request(f, `/tree?repoId=456&workspaceId=${first.id}`)).status,
357 + 400
358 + );
359 + assert.deepEqual(f.calls, []);
360 + const tree = await (
361 + await request(f, `/tree?repoId=123&path=src&workspaceId=${first.id}`)
362 + ).json();
363 + const refId = tree.items[0].refId;
364 + const saved = await f.workspaces.resolveNavigationRef({
365 + ownerId: OWNER,
366 + refId
367 + });
368 + assert.equal(saved.type, 'workspace-add');
369 + assert.equal(saved.workspaceId, first.id);
370 + assert.equal(
371 + (
372 + await request(f, `/workspaces/${second.id}/files`, {
373 + method: 'POST',
374 + body: { refId }
375 + })
376 + ).status,
377 + 400
378 + );
379 + const added = await (
380 + await request(f, `/workspaces/${first.id}/files`, {
381 + method: 'POST',
382 + body: { refId }
383 + })
384 + ).json();
385 + assert.equal(added.workspace.files.length, 2);
386 + assert.equal(added.workspace.files[1].path, 'src/file-0.js');
387 + assert.equal(f.calls.at(-1)[3], HEAD);
388 +});
389 +
390 +test('Studio concurrent file additions enforce the durable file limit and return a bounded policy response', async () => {
391 + const f = fixture();
392 + const workspace = await create(f);
393 + const refs = await f.workspaces.createNavigationRefs({
394 + ownerId: OWNER,
395 + refs: Array.from({ length: 8 }, (_, i) => ({
396 + repoId: 123,
397 + workspaceId: workspace.id,
398 + path: `extra-${i}.js`,
399 + type: 'workspace-add'
400 + }))
401 + });
402 + const add = (refId) =>
403 + request(f, `/workspaces/${workspace.id}/files`, {
404 + method: 'POST',
405 + body: { refId }
406 + });
407 + for (const ref of refs.slice(0, 6))
408 + assert.equal((await add(ref.refId)).status, 200);
409 + const responses = await Promise.all(
410 + refs.slice(6).map((ref) => add(ref.refId))
411 + );
412 + assert.deepEqual(responses.map((result) => result.status).sort(), [200, 422]);
413 + const saved = await f.workspaces.getWorkspace({
414 + ownerId: OWNER,
415 + workspaceId: workspace.id
416 + });
417 + assert.equal(saved.files.length, WORKSPACE_EDITOR_LIMITS.maxFiles);
418 +});
419 +
420 +test('Studio approval seals immutable intent and sends only a signed approval to the fixed private owner without executing writes', async () => {
421 + const f = fixture();
422 + const workspace = await create(f);
423 + const base = `/workspaces/${workspace.id}`;
424 + await request(f, `${base}/files`, {
425 + method: 'PUT',
426 + headers: { 'If-Match': '0' },
427 + body: { path: workspace.path, text: 'after\n' }
428 + });
429 + await request(f, `${base}/message`, {
430 + method: 'PUT',
431 + body: { message: 'edit file' }
432 + });
433 + assert.equal(
434 + (await request(f, `${base}/approval`, { method: 'POST', body: {} })).status,
435 + 400
436 + );
437 + assert.equal(f.messages.length, 0);
438 + assert.equal(
439 + (
440 + await f.workspaces.getWorkspace({
441 + ownerId: OWNER,
442 + workspaceId: workspace.id
443 + })
444 + ).currentIntentId,
445 + null
446 + );
447 + const { review } = await (await request(f, `${base}/diff`)).json();
448 + for (const message of [undefined, null, 7]) {
449 + assert.equal(
450 + (
451 + await request(f, `${base}/approval`, {
452 + method: 'POST',
453 + body: { review, message }
454 + })
455 + ).status,
456 + 400
457 + );
458 + }
459 + f.calls.length = 0;
460 + const response = await request(f, `${base}/approval`, {
461 + method: 'POST',
462 + body: { review, message: ' edit\nfile ' }
463 + });
464 + assert.equal(response.status, 200);
465 + const body = await response.json();
466 + assert.equal(body.approvalRequested, true);
467 + assert.equal(body.workspaceId, workspace.id);
468 + assert.equal(body.targetBranch, `nexa/edit-${workspace.id}`);
469 + assert.equal(body.baseHeadSha, HEAD);
470 + assert.equal(body.expiresAt, NOW + 120_000);
471 + assert.equal(JSON.stringify(body).includes('approve:'), false);
472 + assert.deepEqual(f.calls, []);
473 + assert.equal(f.messages.length, 1);
474 + assert.equal(f.messages[0][0], OWNER);
475 + assert.equal(f.messages[0][1].includes('after'), false);
476 + const button = f.messages[0][2].inline_keyboard
477 + .flat()
478 + .find((value) => value.callback_data?.startsWith('approve:'));
479 + assert.ok(button);
480 + const approved = await f.bot.approvals.verify(button.callback_data.slice(8), {
481 + ownerId: OWNER
482 + });
483 + assert.equal(approved.actionId, 'github.workspace.commit_branch');
484 + assert.equal(approved.risk, 'WRITE');
485 + const sealed = await f.workspaces.getWorkspace({
486 + ownerId: OWNER,
487 + workspaceId: workspace.id
488 + });
489 + assert.equal(approved.input.intentId, sealed.currentIntentId);
490 + const intent = await f.workspaces.getIntent({
491 + ownerId: OWNER,
492 + intentId: sealed.currentIntentId
493 + });
494 + assert.equal(intent.baseHeadSha, HEAD);
495 + assert.equal(intent.state, 'READY');
496 + assert.equal(intent.commitMessageDigest, await digestText('edit file'));
497 + assert.equal(
498 + (
499 + await request(f, `${base}/approval`, {
500 + method: 'POST',
501 + body: { review, chatId: '-100', approved: true }
502 + })
503 + ).status,
504 + 400
505 + );
506 + assert.equal(f.messages.length, 1);
507 +});
508 +
509 +test('Studio rejects oversized and malformed bodies and hides provider errors and draft source', async () => {
510 + const f = fixture();
511 + assert.equal(
512 + (await request(f, '/workspaces', { method: 'POST', body: '{' })).status,
513 + 400
514 + );
515 + assert.equal(
516 + (
517 + await request(f, '/workspaces', {
518 + method: 'POST',
519 + body: 'x'.repeat(5000)
520 + })
521 + ).status,
522 + 413
523 + );
524 + f.github.listRepositories = async () => {
525 + throw new Error('github_pat_secret draft source');
526 + };
527 + const response = await request(f, '/repos');
528 + assert.equal(response.status, 502);
529 + assert.equal((await response.text()).includes('github_pat_secret'), false);
530 +});
531 +
532 +test('Studio approval delivery and metadata failures return bounded errors without leaking the token or source', async () => {
533 + for (const failAt of ['delivery', 'metadata']) {
534 + const f = fixture();
535 + const workspace = await create(f);
536 + const base = `/workspaces/${workspace.id}`;
537 + await request(f, `${base}/files`, {
538 + method: 'PUT',
539 + headers: { 'If-Match': '0' },
540 + body: { path: workspace.path, text: 'after\n' }
541 + });
542 + await request(f, `${base}/message`, {
543 + method: 'PUT',
544 + body: { message: 'edit file' }
545 + });
546 + const { review } = await (await request(f, `${base}/diff`)).json();
547 + if (failAt === 'delivery')
548 + f.bot.telegram.sendMessage = async () => {
549 + throw new Error('secret-token source-text');
550 + };
551 + else
552 + f.bot.router.dispatchCallback = async () => ({ requiresApproval: false });
553 + const response = await request(f, `${base}/approval`, {
554 + method: 'POST',
555 + body: { review, message: 'edit file' }
556 + });
557 + assert.equal(response.status, failAt === 'delivery' ? 502 : 503);
558 + const body = await response.text();
559 + assert.equal(body.includes('secret-token'), false);
560 + assert.equal(body.includes('source-text'), false);
561 + }
562 +});
563 +
564 +test('Studio approval rejects an older reviewed diff after another tab saves and requires a fresh diff', async () => {
565 + const f = fixture();
566 + const workspace = await create(f);
567 + const base = `/workspaces/${workspace.id}`;
568 + const save = (revision, text) =>
569 + request(f, `${base}/files`, {
570 + method: 'PUT',
571 + headers: { 'If-Match': String(revision) },
572 + body: { path: workspace.path, text }
573 + });
574 + await save(0, 'reviewed A\n');
575 + await request(f, `${base}/message`, {
576 + method: 'PUT',
577 + body: { message: 'edit file' }
578 + });
579 + const oldDiff = await (await request(f, `${base}/diff`)).json();
580 + await save(1, 'unreviewed B\n');
581 + f.calls.length = 0;
582 + const stale = await request(f, `${base}/approval`, {
583 + method: 'POST',
584 + body: { review: oldDiff.review, message: 'edit file' }
585 + });
586 + assert.equal(stale.status, 409);
587 + assert.equal(f.messages.length, 0);
588 + assert.deepEqual(f.calls, []);
589 + const currentDiff = await (await request(f, `${base}/diff`)).json();
590 + assert.deepEqual(currentDiff.review, {
591 + baseHeadSha: HEAD,
592 + files: [{ path: workspace.path, revision: 2 }]
593 + });
594 + const fresh = await request(f, `${base}/approval`, {
595 + method: 'POST',
596 + body: { review: currentDiff.review, message: 'edit file' }
597 + });
598 + assert.equal(fresh.status, 200);
599 + assert.equal(f.messages.length, 1);
600 +});
601 +
602 +test('Studio review comparison is atomic when a save races intent sealing', async () => {
603 + const f = fixture();
604 + const workspace = await create(f);
605 + const base = `/workspaces/${workspace.id}`;
606 + await request(f, `${base}/files`, {
607 + method: 'PUT',
608 + headers: { 'If-Match': '0' },
609 + body: { path: workspace.path, text: 'reviewed A\n' }
610 + });
611 + await request(f, `${base}/message`, {
612 + method: 'PUT',
613 + body: { message: 'edit file' }
614 + });
615 + const { review } = await (await request(f, `${base}/diff`)).json();
616 + const seal = f.workspaces.sealIntent.bind(f.workspaces);
617 + f.workspaces.sealIntent = async (input) => {
618 + await f.workspaces.updateWorkspaceFileDraft({
619 + ownerId: OWNER,
620 + workspaceId: workspace.id,
621 + path: workspace.path,
622 + text: 'racing B\n',
623 + digest: 'new-digest',
624 + expectedRevision: 1
625 + });
626 + return seal(input);
627 + };
628 + const response = await request(f, `${base}/approval`, {
629 + method: 'POST',
630 + body: { review, message: 'edit file' }
631 + });
632 + assert.equal(response.status, 409);
633 + assert.equal(f.messages.length, 0);
634 + assert.equal(
635 + (
636 + await f.workspaces.getWorkspace({
637 + ownerId: OWNER,
638 + workspaceId: workspace.id
639 + })
640 + ).currentIntentId,
641 + null
642 + );
643 +});
644 +
645 +test('Studio approval binds the displayed commit message when another tab changes it during sealing', async () => {
646 + const f = fixture();
647 + const workspace = await create(f);
648 + const base = `/workspaces/${workspace.id}`;
649 + await request(f, `${base}/files`, {
650 + method: 'PUT',
651 + headers: { 'If-Match': '0' },
652 + body: { path: workspace.path, text: 'reviewed file\n' }
653 + });
654 + await request(f, `${base}/message`, {
655 + method: 'PUT',
656 + body: { message: 'reviewed message A' }
657 + });
658 + const { review } = await (await request(f, `${base}/diff`)).json();
659 + const seal = f.workspaces.sealIntent.bind(f.workspaces);
660 + f.workspaces.sealIntent = async (input) => {
661 + await f.workspaces.setCommitMessage({
662 + ownerId: OWNER,
663 + workspaceId: workspace.id,
664 + message: 'unreviewed message B',
665 + digest: await digestText('unreviewed message B')
666 + });
667 + return seal(input);
668 + };
669 + const response = await request(f, `${base}/approval`, {
670 + method: 'POST',
671 + body: { review, message: 'reviewed message A' }
672 + });
673 + assert.equal(response.status, 409);
674 + assert.equal(f.messages.length, 0);
675 + const current = await f.workspaces.getWorkspace({
676 + ownerId: OWNER,
677 + workspaceId: workspace.id
678 + });
679 + assert.equal(current.currentIntentId, null);
680 + assert.equal(current.commitMessage, 'unreviewed message B');
681 +});
682 +
683 +test('Studio approval rejects a message changed after its displayed value was saved', async () => {
684 + const f = fixture();
685 + const workspace = await create(f);
686 + const base = `/workspaces/${workspace.id}`;
687 + await request(f, `${base}/files`, {
688 + method: 'PUT',
689 + headers: { 'If-Match': '0' },
690 + body: { path: workspace.path, text: 'reviewed file\n' }
691 + });
692 + await request(f, `${base}/message`, {
693 + method: 'PUT',
694 + body: { message: 'reviewed message A' }
695 + });
696 + const { review } = await (await request(f, `${base}/diff`)).json();
697 + await request(f, `${base}/message`, {
698 + method: 'PUT',
699 + body: { message: 'unreviewed message B' }
700 + });
701 + const issued = [];
702 + const issue = f.bot.approvals.issue.bind(f.bot.approvals);
703 + f.bot.approvals.issue = async (payload) => {
704 + const token = await issue(payload);
705 + issued.push(token);
706 + return token;
707 + };
708 + f.calls.length = 0;
709 + const response = await request(f, `${base}/approval`, {
710 + method: 'POST',
711 + body: { review, message: 'reviewed message A' }
712 + });
713 + assert.equal(response.status, 409);
714 + assert.equal((await response.text()).includes('unreviewed message B'), false);
715 + assert.equal(issued.length, 0);
716 + assert.equal(f.messages.length, 0);
717 + assert.deepEqual(f.calls, []);
718 + const current = await f.workspaces.getWorkspace({
719 + ownerId: OWNER,
720 + workspaceId: workspace.id
721 + });
722 + assert.equal(current.currentIntentId, null);
723 + assert.equal(current.state, 'DRAFT');
724 + assert.equal(current.commitMessage, 'unreviewed message B');
725 +});
726 +
727 +test('Studio approval rejects an unreviewed proposed message even if the current message is restored', async () => {
728 + const f = fixture();
729 + const workspace = await create(f);
730 + const base = `/workspaces/${workspace.id}`;
731 + await request(f, `${base}/files`, {
732 + method: 'PUT',
733 + headers: { 'If-Match': '0' },
734 + body: { path: workspace.path, text: 'reviewed file\n' }
735 + });
736 + await request(f, `${base}/message`, {
737 + method: 'PUT',
738 + body: { message: 'reviewed message A' }
739 + });
740 + const { review } = await (await request(f, `${base}/diff`)).json();
741 + await request(f, `${base}/message`, {
742 + method: 'PUT',
743 + body: { message: 'unreviewed message B' }
744 + });
745 + const seal = f.workspaces.sealIntent.bind(f.workspaces);
746 + f.workspaces.sealIntent = async (input) => {
747 + await f.workspaces.setCommitMessage({
748 + ownerId: OWNER,
749 + workspaceId: workspace.id,
750 + message: 'reviewed message A',
751 + digest: await digestText('reviewed message A')
752 + });
753 + return seal(input);
754 + };
755 + f.calls.length = 0;
756 + const response = await request(f, `${base}/approval`, {
757 + method: 'POST',
758 + body: { review, message: 'reviewed message A' }
759 + });
760 + assert.equal(response.status, 409);
761 + assert.equal(f.messages.length, 0);
762 + assert.deepEqual(f.calls, []);
763 + const current = await f.workspaces.getWorkspace({
764 + ownerId: OWNER,
765 + workspaceId: workspace.id
766 + });
767 + assert.equal(current.currentIntentId, null);
768 + assert.equal(current.commitMessage, 'reviewed message A');
769 +});
770 +
771 +test('Studio approval keeps the exact sealed intent when another tab seals a replacement', async () => {
772 + const f = fixture();
773 + const workspace = await create(f);
774 + const base = `/workspaces/${workspace.id}`;
775 + await request(f, `${base}/files`, {
776 + method: 'PUT',
777 + headers: { 'If-Match': '0' },
778 + body: { path: workspace.path, text: 'reviewed file\n' }
779 + });
780 + await request(f, `${base}/message`, {
781 + method: 'PUT',
782 + body: { message: 'reviewed message A' }
783 + });
784 + const { review } = await (await request(f, `${base}/diff`)).json();
785 + const seal = f.workspaces.sealIntent.bind(f.workspaces);
786 + let reviewedIntent;
787 + f.workspaces.sealIntent = async (input) => {
788 + reviewedIntent = await seal(input);
789 + f.workspaces.sealIntent = seal;
790 + await f.workspaces.setCommitMessage({
791 + ownerId: OWNER,
792 + workspaceId: workspace.id,
793 + message: 'unreviewed message B',
794 + digest: await digestText('unreviewed message B')
795 + });
796 + await createWorkspaceController(f).sealWorkspaceIntent({
797 + ownerId: OWNER,
798 + workspaceId: workspace.id
799 + });
800 + return reviewedIntent;
801 + };
802 + f.calls.length = 0;
803 + const response = await request(f, `${base}/approval`, {
804 + method: 'POST',
805 + body: { review, message: 'reviewed message A' }
806 + });
807 + assert.equal(response.status, 200);
808 + assert.equal(f.messages.length, 1);
809 + const button = f.messages[0][2].inline_keyboard
810 + .flat()
811 + .find((value) => value.callback_data?.startsWith('approve:'));
812 + const approved = await f.bot.approvals.verify(button.callback_data.slice(8), {
813 + ownerId: OWNER
814 + });
815 + assert.equal(approved.input.intentId, reviewedIntent.id);
816 + assert.equal(
817 + reviewedIntent.commitMessageDigest,
818 + await digestText('reviewed message A')
819 + );
820 + const current = await f.workspaces.getWorkspace({
821 + ownerId: OWNER,
822 + workspaceId: workspace.id
823 + });
824 + assert.notEqual(current.currentIntentId, reviewedIntent.id);
825 + await assert.rejects(
826 + commitWorkspaceIntent({
827 + ...f,
828 + ownerId: OWNER,
829 + repoId: 123,
830 + intentId: reviewedIntent.id
831 + }),
832 + /Workspace material changed/i
833 + );
834 + assert.deepEqual(f.calls, []);
835 +});
836 +
837 +test('Studio rejects unsafe owner configuration, malformed paths and foreign workspace identifiers', async () => {
838 + const f = fixture();
839 + f.env.OWNER_TELEGRAM_ID = '-100';
840 + assert.equal((await request(f, '/repos')).status, 503);
841 + assert.deepEqual(f.calls, []);
842 + assert.equal(f.states.size, 0);
843 + f.env.OWNER_TELEGRAM_ID = OWNER;
844 + for (const path of ['../secret', '/secret', 'src//a', 'src\\a', 'src\0a']) {
845 + assert.equal(
846 + (await request(f, `/tree?repoId=123&path=${encodeURIComponent(path)}`))
847 + .status,
848 + 400
849 + );
850 + }
851 + assert.deepEqual(f.calls, []);
852 + const foreign = await f.workspaces.createWorkspace({
853 + ownerId: '99',
854 + repoId: 123,
855 + path: 'foreign.js',
856 + originalText: 'private',
857 + originalDigest: 'digest',
858 + baseBranch: 'main',
859 + baseHeadSha: HEAD,
860 + baseTreeSha: TREE
861 + });
862 + for (const [method, suffix, body] of [
863 + ['GET', '', undefined],
864 + ['DELETE', '', undefined],
865 + ['PUT', '/files', { path: 'foreign.js', text: 'attacker' }],
866 + ['POST', '/approval', {}]
867 + ]) {
868 + assert.equal(
869 + (
870 + await request(f, `/workspaces/${foreign.id}${suffix}`, {
871 + method,
872 + body,
873 + headers: { 'If-Match': '0' }
874 + })
875 + ).status,
876 + 404
877 + );
878 + }
879 + assert.equal(
880 + (
881 + await f.workspaces.getWorkspace({
882 + ownerId: '99',
883 + workspaceId: foreign.id
884 + })
885 + ).draftText,
886 + 'private'
887 + );
888 +});
889 +
890 +test('GitHub repository listing traverses all Link pages at per_page=100 without leaking credentials to another origin', async () => {
891 + const originalFetch = globalThis.fetch;
892 + const requested = [];
893 + globalThis.fetch = async (url) => {
894 + requested.push(String(url));
895 + const page = new URL(url).searchParams.get('page');
896 + return Response.json(
897 + [{ id: page === '2' ? 2 : 1, name: 'repo', full_name: 'owner/repo' }],
898 + {
899 + headers:
900 + page === '2'
901 + ? {}
902 + : {
903 + Link: '<https://api.github.com/user/repos?per_page=100&page=2>; rel="next"'
904 + }
905 + }
906 + );
907 + };
908 + try {
909 + const repos = await new GitHubService('github_pat_test').listRepositories();
910 + assert.equal(repos.length, 2);
911 + assert.equal(new URL(requested[0]).searchParams.get('per_page'), '100');
912 + assert.equal(requested.length, 2);
913 + requested.length = 0;
914 + globalThis.fetch = async (url) => {
915 + requested.push(String(url));
916 + return Response.json([], {
917 + headers: {
918 + Link: '<https://attacker.test/user/repos?page=2>; rel="next"'
919 + }
920 + });
921 + };
922 + await assert.rejects(
923 + () => new GitHubService('github_pat_test').listRepositories(),
924 + /pagination|page/i
925 + );
926 + assert.equal(requested.length, 1);
927 + } finally {
928 + globalThis.fetch = originalFetch;
929 + }
930 +});
test/studio-assets.test.js new
+101
@@ -0,0 +1,101 @@
1 +import test from 'node:test';
2 +import assert from 'node:assert/strict';
3 +
4 +let module = {};
5 +try {
6 + module = await import('../src/studio-assets.js');
7 +} catch {}
8 +const serve = (...args) => {
9 + assert.equal(
10 + typeof module.handleStudioAssetsRequest,
11 + 'function',
12 + 'Studio assets handler must exist'
13 + );
14 + return module.handleStudioAssetsRequest(...args);
15 +};
16 +const html =
17 + '<!doctype html><html lang="fa" dir="rtl"><meta name="csp-nonce" content="__NEXA_NONCE__"><script type="module" src="/studio/assets/app.js"></script></html>';
18 +
19 +test('Studio entry serves a real asset shell with fresh nonce and no unsafe-inline', async () => {
20 + const calls = [];
21 + const env = {
22 + ASSETS: {
23 + fetch: async (request) => {
24 + calls.push(new URL(request.url).pathname);
25 + return new Response(html, { headers: { 'content-type': 'text/html' } });
26 + }
27 + }
28 + };
29 + const first = await serve(new Request('https://app.test/studio/'), env);
30 + const second = await serve(new Request('https://app.test/studio/'), env);
31 + assert.equal(first.status, 200);
32 + const body = await first.text();
33 + const nonce = body.match(/content="([a-f0-9]{32})"/)[1];
34 + assert.match(
35 + first.headers.get('content-security-policy'),
36 + new RegExp("style-src 'self' 'nonce-" + nonce + "'")
37 + );
38 + assert.doesNotMatch(
39 + first.headers.get('content-security-policy'),
40 + /unsafe-inline/
41 + );
42 + assert.match(
43 + first.headers.get('content-security-policy'),
44 + /script-src 'self' https:\/\/telegram\.org/
45 + );
46 + assert.equal(first.headers.get('cache-control'), 'no-store');
47 + assert.equal(first.headers.get('referrer-policy'), 'no-referrer');
48 + assert.doesNotMatch(body, /__NEXA_NONCE__/);
49 + assert.notEqual(
50 + first.headers.get('content-security-policy'),
51 + second.headers.get('content-security-policy')
52 + );
53 + assert.deepEqual(calls, ['/studio/', '/studio/']);
54 +});
55 +
56 +test('Studio normalizes its public entry, serves static files and leaves other routes to Worker', async () => {
57 + const redirect = await serve(new Request('https://app.test/studio'), {});
58 + assert.equal(redirect.status, 308);
59 + assert.equal(redirect.headers.get('location'), '/studio/');
60 + const response = await serve(
61 + new Request('https://app.test/studio/assets/app.js'),
62 + {
63 + ASSETS: {
64 + fetch: async () =>
65 + new Response('export {}', {
66 + headers: { 'content-type': 'text/javascript' }
67 + })
68 + }
69 + }
70 + );
71 + assert.equal(await response.text(), 'export {}');
72 + assert.equal(response.headers.get('x-content-type-options'), 'nosniff');
73 + assert.equal(await serve(new Request('https://app.test/status'), {}), null);
74 +});
75 +
76 +test('missing or failing assets return a fixed error without leaking provider text', async () => {
77 + for (const env of [
78 + {},
79 + {
80 + ASSETS: {
81 + fetch: async () => {
82 + throw new Error('PRIVATE_ASSET_PROVIDER_SENTINEL');
83 + }
84 + }
85 + }
86 + ]) {
87 + const response = await serve(new Request('https://app.test/studio/'), env);
88 + assert.equal(response.status, 503);
89 + assert.doesNotMatch(
90 + await response.text(),
91 + /PRIVATE_ASSET_PROVIDER_SENTINEL/
92 + );
93 + }
94 +});
95 +
96 +test('invalid HTML without its nonce placeholder fails closed', async () => {
97 + const response = await serve(new Request('https://app.test/studio/'), {
98 + ASSETS: { fetch: async () => new Response('<html>broken</html>') }
99 + });
100 + assert.equal(response.status, 503);
101 +});
test/studio-entry.test.js new
+305
@@ -0,0 +1,305 @@
1 +import test from 'node:test';
2 +import assert from 'node:assert/strict';
3 +import { GuidedNexaDevBot } from '../src/guide-bot.js';
4 +import { KillSwitchGuidedNexaDevBot } from '../src/kill-switch-bot.js';
5 +import * as config from '../src/config.js';
6 +import { TelegramClient } from '../src/telegram.js';
7 +
8 +const STUDIO_URL = 'https://acceptance.test/studio/';
9 +const ownerMessage = (text, extra = {}) => ({
10 + message_id: 1,
11 + from: { id: 42 },
12 + chat: { id: 42, type: 'private' },
13 + text,
14 + ...extra
15 +});
16 +
17 +function studioBot(env = {}, { failMenu = false } = {}) {
18 + const bot = new KillSwitchGuidedNexaDevBot({
19 + OWNER_TELEGRAM_ID: '42',
20 + TELEGRAM_BOT_TOKEN: 'synthetic-bot-credential',
21 + STUDIO_URL,
22 + ...env
23 + });
24 + const effects = [];
25 + bot.telegram.fetchFn = async (url, options) => {
26 + const method = new URL(url).pathname.split('/').at(-1);
27 + const payload = JSON.parse(options.body);
28 + effects.push({ method, payload });
29 + if (method === 'setChatMenuButton' && failMenu)
30 + throw new Error('PRIVATE_PROVIDER_ERROR_SENTINEL');
31 + return Response.json({
32 + ok: true,
33 + result:
34 + method === 'sendMessage' || method === 'editMessageText'
35 + ? { message_id: 10, chat: { id: 42, type: 'private' } }
36 + : true
37 + });
38 + };
39 + return { bot, effects };
40 +}
41 +
42 +function assertStudioButton(payload) {
43 + assert.deepEqual(payload.reply_markup, {
44 + inline_keyboard: [
45 + [{ text: 'باز کردن Nexa Studio', web_app: { url: STUDIO_URL } }]
46 + ]
47 + });
48 + assert.match(payload.text, /Nexa Studio/);
49 +}
50 +
51 +test('/start clears the old keyboard and offers a single Studio launch action', async () => {
52 + const { bot, effects } = studioBot();
53 + const result = await bot.handleUpdate({ message: ownerMessage('/start') });
54 + const sent = effects.filter(({ method }) => method === 'sendMessage');
55 +
56 + assert.equal(result.ok, true);
57 + assert.equal(result.command, 'start');
58 + assert.equal(result.studioEntry, true);
59 + assert.equal(result.menuButtonConfigured, true);
60 + assert.equal(sent.length, 2);
61 + assert.deepEqual(sent[0].payload.reply_markup, { remove_keyboard: true });
62 + assertStudioButton(sent[1].payload);
63 + assert.deepEqual(
64 + effects.find(({ method }) => method === 'setChatMenuButton')?.payload,
65 + {
66 + chat_id: 42,
67 + menu_button: {
68 + type: 'web_app',
69 + text: 'Nexa Studio',
70 + web_app: { url: STUDIO_URL }
71 + }
72 + }
73 + );
74 + assert.equal(
75 + effects.some(({ payload }) => payload.reply_markup?.keyboard),
76 + false
77 + );
78 +});
79 +
80 +test('/menu and the stale main quick-menu text launch Studio before pending input', async (t) => {
81 + for (const text of ['/menu', '🏠 منوی اصلی']) {
82 + await t.test(text, async () => {
83 + const { bot, effects } = studioBot();
84 + bot.workspaceStore = {
85 + isConfigured: () => true,
86 + async getPendingInput() {
87 + assert.fail('main navigation must precede stale workspace input');
88 + }
89 + };
90 + const result = await bot.handleMessage(ownerMessage(text));
91 +
92 + assert.equal(result.ok, true);
93 + assert.equal(result.studioEntry, true);
94 + assertStudioButton(effects.at(-1).payload);
95 + assert.equal(
96 + effects.some(({ method }) => method === 'setChatMenuButton'),
97 + false
98 + );
99 + });
100 + }
101 +});
102 +
103 +test('start payloads launch Studio but unrelated start-like commands do not configure a menu', async () => {
104 + const { bot, effects } = studioBot();
105 + await bot.handleMessage(ownerMessage('/start@NexaBot launch'));
106 + assertStudioButton(effects.at(-1).payload);
107 + assert.equal(
108 + effects.filter(({ method }) => method === 'setChatMenuButton').length,
109 + 1
110 + );
111 +
112 + effects.length = 0;
113 + await bot.handleMessage(ownerMessage('/starter'));
114 + assert.equal(
115 + effects.some(({ method }) => method === 'setChatMenuButton'),
116 + false
117 + );
118 +});
119 +
120 +test('menu setup failure keeps the primary launch action and returns metadata only', async () => {
121 + const { bot, effects } = studioBot({}, { failMenu: true });
122 + const result = await bot.handleMessage(ownerMessage('/start'));
123 +
124 + assert.equal(result.ok, true);
125 + assert.equal(result.menuButtonConfigured, false);
126 + assertStudioButton(effects.at(-1).payload);
127 + assert.equal(
128 + JSON.stringify(result).includes('PRIVATE_PROVIDER_ERROR_SENTINEL'),
129 + false
130 + );
131 +});
132 +
133 +test('direct entry handlers require the configured owner and that owner’s private chat before effects', async (t) => {
134 + for (const message of [
135 + ownerMessage('/start', { from: { id: 7 } }),
136 + ownerMessage('/start', { from: undefined }),
137 + ownerMessage('/start', { chat: { id: -42, type: 'group' } }),
138 + ownerMessage('/start', { chat: { id: 99, type: 'private' } }),
139 + ownerMessage('/start', { chat: { id: 42 } }),
140 + ownerMessage('/menu', { chat: { id: 42, type: 'supergroup' } })
141 + ]) {
142 + await t.test(JSON.stringify(message), async () => {
143 + const { bot, effects } = studioBot();
144 + const result = await bot.handleMessage(message);
145 + assert.equal(result.ok, false);
146 + assert.equal(result.reason, 'owner_private_chat_required');
147 + assert.deepEqual(effects, []);
148 + });
149 + }
150 + const { bot, effects } = studioBot({ OWNER_TELEGRAM_ID: '' });
151 + assert.equal((await bot.handleMessage(ownerMessage('/start'))).ok, false);
152 + assert.deepEqual(effects, []);
153 +});
154 +
155 +test('main-menu callback edits the primary Studio entry without setting chat configuration', async () => {
156 + const { bot, effects } = studioBot();
157 + const result = await bot.handleCallbackQuery({
158 + id: 'main',
159 + data: 'menu:main',
160 + from: { id: 42 },
161 + message: ownerMessage(undefined)
162 + });
163 +
164 + assert.equal(result.ok, true);
165 + assert.equal(result.edited, true);
166 + assert.deepEqual(
167 + effects.map(({ method }) => method),
168 + ['answerCallbackQuery', 'editMessageText']
169 + );
170 + assertStudioButton(effects.at(-1).payload);
171 +});
172 +
173 +test('main-menu callback fails closed outside the owner private chat', async () => {
174 + const { bot, effects } = studioBot();
175 + const result = await bot.handleCallbackQuery({
176 + id: 'main',
177 + data: 'menu:main',
178 + from: { id: 7 },
179 + message: ownerMessage(undefined)
180 + });
181 + assert.equal(result.ok, false);
182 + assert.deepEqual(effects, []);
183 +});
184 +
185 +test('invalid explicit Studio URLs produce a fixed Persian error without exposing URL input', async (t) => {
186 + for (const value of [
187 + '',
188 + null,
189 + 'http://acceptance.test/studio/',
190 + 'https://PRIVATE_URL_SENTINEL:secret@acceptance.test/studio/',
191 + 'https://acceptance.test/studio/?token=PRIVATE_URL_SENTINEL',
192 + 'https://acceptance.test/studio/?',
193 + 'https://acceptance.test/studio/#PRIVATE_URL_SENTINEL',
194 + 'https://acceptance.test/studio/#',
195 + 'https://acceptance.test/workspace/editor',
196 + 'PRIVATE_URL_SENTINEL'
197 + ]) {
198 + await t.test(String(value), async () => {
199 + const { bot, effects } = studioBot({ STUDIO_URL: value });
200 + const result = await bot.handleMessage(ownerMessage('/start'));
201 + assert.equal(result.ok, false);
202 + assert.equal(result.invalidStudioUrl, true);
203 + assert.equal(effects.length, 1);
204 + assert.equal(effects[0].method, 'sendMessage');
205 + assert.equal(
206 + effects[0].payload.text,
207 + '⚠️ نشانی Nexa Studio پیکربندی نشده است. با مدیر ربات تماس بگیرید.'
208 + );
209 + assert.deepEqual(effects[0].payload.reply_markup, {
210 + remove_keyboard: true
211 + });
212 + assert.equal(
213 + JSON.stringify({ effects, result }).includes('PRIVATE_URL_SENTINEL'),
214 + false
215 + );
216 + });
217 + }
218 +});
219 +
220 +test('Studio URLs normalize the exact HTTPS route and default only when unspecified', async () => {
221 + assert.equal(typeof config.studioAppUrl, 'function');
222 + assert.equal(
223 + config.studioAppUrl('https://acceptance.test/studio'),
224 + STUDIO_URL
225 + );
226 + assert.equal(config.studioAppUrl(STUDIO_URL), STUDIO_URL);
227 + assert.equal(
228 + config.studioAppUrl(),
229 + 'https://nexa-dev-bot.davoodmehraban89.workers.dev/studio/'
230 + );
231 + for (const value of [
232 + '',
233 + null,
234 + 42,
235 + 'https://acceptance.test/studio/child',
236 + 'https://acceptance.test/studio//'
237 + ])
238 + assert.equal(config.studioAppUrl(value), '');
239 +});
240 +
241 +test('TelegramClient sends a scoped web_app chat menu payload through the Bot API', async () => {
242 + const calls = [];
243 + const client = new TelegramClient('synthetic-bot-credential', {
244 + fetch: async (url, options) => {
245 + calls.push({ url, payload: JSON.parse(options.body) });
246 + return Response.json({ ok: true, result: true });
247 + }
248 + });
249 + assert.equal(typeof client.setChatMenuButton, 'function');
250 + await client.setChatMenuButton(42, {
251 + type: 'web_app',
252 + text: 'Nexa Studio',
253 + web_app: { url: STUDIO_URL }
254 + });
255 + assert.equal(
256 + new URL(calls[0].url).pathname.split('/').at(-1),
257 + 'setChatMenuButton'
258 + );
259 + assert.deepEqual(calls[0].payload, {
260 + chat_id: 42,
261 + menu_button: {
262 + type: 'web_app',
263 + text: 'Nexa Studio',
264 + web_app: { url: STUDIO_URL }
265 + }
266 + });
267 +});
268 +
269 +test('the existing secret guard intercepts token messages before any Studio launch effects', async () => {
270 + const { bot, effects } = studioBot();
271 + const result = await bot.handleUpdate({
272 + message: ownerMessage('github_pat_synthetic_noncredential_fixture')
273 + });
274 + assert.equal(result.secretRejected, true);
275 + assert.deepEqual(
276 + effects.map(({ method }) => method),
277 + ['deleteMessage', 'sendMessage']
278 + );
279 +});
280 +
281 +test('direct start handling rejects a token caption before configuring the chat menu', async () => {
282 + const { bot, effects } = studioBot();
283 + const result = await bot.handleMessage(
284 + ownerMessage('/start', {
285 + caption: 'github_pat_synthetic_noncredential_fixture'
286 + })
287 + );
288 + assert.equal(result.secretRejected, true);
289 + assert.deepEqual(
290 + effects.map(({ method }) => method),
291 + ['deleteMessage', 'sendMessage']
292 + );
293 +});
294 +
295 +test('legacy guide routing stays available without restoring a persistent keyboard', async () => {
296 + const bot = new GuidedNexaDevBot({ OWNER_TELEGRAM_ID: '42' });
297 + const sent = [];
298 + bot.telegram.sendMessage = async (chatId, text, replyMarkup) => {
299 + sent.push({ chatId, text, replyMarkup });
300 + return { ok: true };
301 + };
302 + const result = await bot.handleMessage(ownerMessage('📘 راهنما'));
303 + assert.equal(result.quickMenu, 'help');
304 + assert.match(sent[0].text, /راهنمای Nexa Dev/);
305 +});
test/studio-frontend.test.js new
+1127
@@ -0,0 +1,1127 @@
1 +import assert from 'node:assert/strict';
2 +import { after, before, test } from 'node:test';
3 +import { build } from 'esbuild';
4 +import { mkdir, rm } from 'node:fs/promises';
5 +import { pathToFileURL } from 'node:url';
6 +import { JSDOM } from 'jsdom';
7 +import React, { act } from 'react';
8 +import { EditorView } from '@codemirror/view';
9 +
10 +let App;
11 +const bundle = `.wrangler/studio-frontend-test-${process.pid}.mjs`;
12 +const limits = {
13 + maxChars: 20000,
14 + maxBytes: 65536,
15 + maxFiles: 8,
16 + maxAggregateBytes: 131072
17 +};
18 +const repository = {
19 + id: 17,
20 + name: 'hello',
21 + fullName: 'owner/hello',
22 + defaultBranch: 'main',
23 + private: false,
24 + description: 'A real repository'
25 +};
26 +const source = '<img src=x onerror="window.pwned=true">\nconst answer = 1;';
27 +function workspace(text = source, revision = 0) {
28 + return {
29 + id: 'Abcdef1234',
30 + repoId: 17,
31 + repoFullName: 'owner/hello',
32 + baseBranch: 'main',
33 + baseHeadSha: 'a'.repeat(40),
34 + state: 'DRAFT',
35 + path: 'index.js',
36 + files: [{ path: 'index.js', draftText: text, revision }],
37 + commitMessage: ''
38 + };
39 +}
40 +
41 +before(async () => {
42 + await mkdir('.wrangler', { recursive: true });
43 + await build({
44 + entryPoints: ['web/src/App.tsx'],
45 + outfile: bundle,
46 + bundle: true,
47 + packages: 'external',
48 + platform: 'node',
49 + format: 'esm',
50 + jsx: 'automatic',
51 + logLevel: 'silent'
52 + });
53 + ({ App } = await import(pathToFileURL(`${process.cwd()}/${bundle}`)));
54 +});
55 +after(() => rm(bundle, { force: true }));
56 +
57 +async function setup({
58 + telegram = true,
59 + respond,
60 + stored = {},
61 + storageUnavailable = false
62 +} = {}) {
63 + const dom = new JSDOM(
64 + '<!doctype html><html><head><meta name="csp-nonce" content="test-nonce"></head><body><div id="root"></div></body></html>',
65 + { url: 'https://studio.example/studio/', pretendToBeVisual: true }
66 + );
67 + for (const [key, value] of Object.entries(stored))
68 + dom.window.localStorage.setItem(key, value);
69 + if (storageUnavailable)
70 + Object.defineProperty(dom.window, 'localStorage', {
71 + get() {
72 + throw new Error('Storage unavailable');
73 + }
74 + });
75 + const previous = new Map();
76 + for (const key of [
77 + 'window',
78 + 'document',
79 + 'navigator',
80 + 'HTMLElement',
81 + 'MutationObserver',
82 + 'Node',
83 + 'NodeFilter',
84 + 'DOMRect',
85 + 'getComputedStyle',
86 + 'requestAnimationFrame',
87 + 'cancelAnimationFrame'
88 + ]) {
89 + previous.set(key, Object.getOwnPropertyDescriptor(globalThis, key));
90 + Object.defineProperty(globalThis, key, {
91 + configurable: true,
92 + writable: true,
93 + value:
94 + typeof dom.window[key] === 'function' &&
95 + [
96 + 'getComputedStyle',
97 + 'requestAnimationFrame',
98 + 'cancelAnimationFrame'
99 + ].includes(key)
100 + ? dom.window[key].bind(dom.window)
101 + : dom.window[key]
102 + });
103 + }
104 + dom.window.Range.prototype.getClientRects = () => [];
105 + dom.window.Range.prototype.getBoundingClientRect = () =>
106 + new dom.window.DOMRect();
107 + globalThis.IS_REACT_ACT_ENVIRONMENT = true;
108 + const calls = [];
109 + let closed = false;
110 + if (telegram) {
111 + dom.window.Telegram = {
112 + WebApp: {
113 + initData: 'opaque-signed-init-data',
114 + ready() {},
115 + expand() {},
116 + enableClosingConfirmation() {},
117 + disableClosingConfirmation() {},
118 + close() {
119 + closed = true;
120 + }
121 + }
122 + };
123 + }
124 + const fetcher = async (url, init = {}) => {
125 + const call = {
126 + url: String(url),
127 + method: init.method || 'GET',
128 + headers: new Headers(init.headers),
129 + body: init.body ? JSON.parse(init.body) : undefined
130 + };
131 + calls.push(call);
132 + const custom = await respond?.(call, calls);
133 + if (custom)
134 + return Response.json(custom.body, { status: custom.status || 200 });
135 + if (call.url === '/api/v1/studio') {
136 + return Response.json({
137 + ok: true,
138 + user: { name: 'داوود' },
139 + limits,
140 + version: '1'
141 + });
142 + }
143 + if (call.url === '/api/v1/studio/repos') {
144 + return Response.json({ ok: true, repositories: [repository] });
145 + }
146 + if (call.url.startsWith('/api/v1/studio/tree?')) {
147 + return Response.json({
148 + ok: true,
149 + repository,
150 + path: '',
151 + items: [
152 + {
153 + refId: 'FileRef123',
154 + name: 'index.js',
155 + path: 'index.js',
156 + type: 'file',
157 + size: source.length
158 + }
159 + ]
160 + });
161 + }
162 + if (call.url === '/api/v1/studio/workspaces' && call.method === 'POST') {
163 + return Response.json({ ok: true, workspace: workspace(), limits });
164 + }
165 + if (call.url.endsWith('/files') && call.method === 'PUT') {
166 + return Response.json({
167 + ok: true,
168 + workspace: workspace(call.body.text, 1),
169 + limits
170 + });
171 + }
172 + if (call.url.endsWith('/diff')) {
173 + return Response.json({
174 + ok: true,
175 + review: {
176 + baseHeadSha: 'a'.repeat(40),
177 + files: [{ path: 'index.js', revision: 1 }]
178 + },
179 + diff: {
180 + text: '--- a/index.js\n+++ b/index.js\n-const answer = 1;\n+const answer = 2;',
181 + additions: 1,
182 + deletions: 1,
183 + truncated: false
184 + }
185 + });
186 + }
187 + if (call.url.endsWith('/message')) {
188 + return Response.json({
189 + ok: true,
190 + workspace: {
191 + ...workspace('const answer = 2;', 1),
192 + commitMessage: call.body.message
193 + },
194 + limits
195 + });
196 + }
197 + if (call.url.endsWith('/approval')) {
198 + return Response.json({
199 + ok: true,
200 + approvalRequested: true,
201 + workspaceId: 'Abcdef1234',
202 + targetBranch: 'nexa/edit-Abcdef1234',
203 + baseHeadSha: 'a'.repeat(40),
204 + expiresAt: Date.now() + 600000
205 + });
206 + }
207 + if (call.url === '/api/v1/studio/workspaces/Abcdef1234') {
208 + return Response.json({
209 + ok: true,
210 + workspace: workspace('const remote = true;', 4),
211 + limits
212 + });
213 + }
214 + throw new Error(`Unexpected API route: ${call.method} ${call.url}`);
215 + };
216 + const { createRoot } = await import('react-dom/client');
217 + let root = createRoot(dom.window.document.getElementById('root'));
218 + await act(async () => root.render(React.createElement(App, { fetcher })));
219 + async function remount() {
220 + await act(async () => root.unmount());
221 + root = createRoot(dom.window.document.getElementById('root'));
222 + await act(async () => root.render(React.createElement(App, { fetcher })));
223 + }
224 + const buttons = () => [...dom.window.document.querySelectorAll('button')];
225 + async function click(label) {
226 + const button = buttons().find((entry) => entry.textContent.includes(label));
227 + assert.ok(button, `Button exists: ${label}`);
228 + assert.equal(button.disabled, false, `Button enabled: ${label}`);
229 + await act(async () => button.click());
230 + }
231 + async function edit(text) {
232 + const view = EditorView.findFromDOM(
233 + dom.window.document.querySelector('.cm-editor')
234 + );
235 + assert.ok(view, 'Real CodeMirror editor mounted');
236 + await act(async () =>
237 + view.dispatch({
238 + changes: { from: 0, to: view.state.doc.length, insert: text }
239 + })
240 + );
241 + }
242 + async function input(label, value) {
243 + const element = dom.window.document.querySelector(
244 + `[aria-label="${label}"]`
245 + );
246 + assert.ok(element, `Input exists: ${label}`);
247 + await act(async () => {
248 + Object.getOwnPropertyDescriptor(
249 + dom.window.HTMLInputElement.prototype,
250 + 'value'
251 + ).set.call(element, value);
252 + element.dispatchEvent(new dom.window.Event('input', { bubbles: true }));
253 + element.dispatchEvent(new dom.window.Event('change', { bubbles: true }));
254 + });
255 + }
256 + async function cleanup() {
257 + await act(async () => root.unmount());
258 + dom.window.close();
259 + for (const [key, descriptor] of previous) {
260 + if (descriptor) Object.defineProperty(globalThis, key, descriptor);
261 + else delete globalThis[key];
262 + }
263 + delete globalThis.IS_REACT_ACT_ENVIRONMENT;
264 + }
265 + return {
266 + dom,
267 + calls,
268 + click,
269 + edit,
270 + input,
271 + remount,
272 + cleanup,
273 + get closed() {
274 + return closed;
275 + }
276 + };
277 +}
278 +
279 +async function openEditor(ui) {
280 + await ui.click('hello');
281 + await ui.click('index.js');
282 +}
283 +
284 +test('refuses browser access outside Telegram without issuing authenticated requests', async () => {
285 + const ui = await setup({ telegram: false });
286 + try {
287 + assert.match(ui.dom.window.document.body.textContent, /تلگرام/);
288 + assert.equal(ui.calls.length, 0);
289 + } finally {
290 + await ui.cleanup();
291 + }
292 +});
293 +
294 +test('real repository → literal CodeMirror edits → diff → Telegram approval, never invented success', async () => {
295 + const ui = await setup();
296 + try {
297 + await openEditor(ui);
298 + assert.equal(ui.dom.window.document.querySelector('img'), null);
299 + assert.equal(ui.dom.window.pwned, undefined);
300 + assert.match(
301 + ui.dom.window.document.querySelector('.cm-editor').textContent,
302 + /<img/
303 + );
304 + await ui.edit('const answer = 2;');
305 + await ui.click('ذخیره تغییرات');
306 + const save = ui.calls.find(
307 + (entry) => entry.method === 'PUT' && entry.url.endsWith('/files')
308 + );
309 + assert.deepEqual(save.body, {
310 + path: 'index.js',
311 + text: 'const answer = 2;'
312 + });
313 + assert.equal(save.headers.get('if-match'), '0');
314 + assert.ok(
315 + ui.calls.every(
316 + (entry) =>
317 + entry.headers.get('x-telegram-init-data') ===
318 + 'opaque-signed-init-data'
319 + )
320 + );
321 + assert.deepEqual(Object.entries(ui.dom.window.localStorage), [
322 + ['nexa.studio.workspace', 'Abcdef1234']
323 + ]);
324 + assert.equal(ui.dom.window.location.search, '');
325 + await ui.click('بازبینی تغییرات');
326 + assert.match(
327 + ui.dom.window.document.querySelector('.diff-view').textContent,
328 + /const answer = 2/
329 + );
330 + assert.match(
331 + ui.dom.window.document.body.textContent,
332 + /nexa\/edit-Abcdef1234/
333 + );
334 + await ui.input('پیام Commit', 'Update answer');
335 + await ui.click('درخواست تأیید امن');
336 + assert.match(ui.dom.window.document.body.textContent, /تلگرام/);
337 + assert.equal(
338 + ui.calls.filter((entry) => entry.url.endsWith('/approval')).length,
339 + 1
340 + );
341 + assert.equal(
342 + ui.calls.filter((entry) => entry.url.endsWith('/message'))[0].body
343 + .message,
344 + 'Update answer'
345 + );
346 + assert.equal(ui.closed, false);
347 + assert.doesNotMatch(
348 + ui.dom.window.document.body.textContent,
349 + /Commit با موفقیت ثبت شد/
350 + );
351 + assert.equal(ui.dom.window.document.querySelector('img'), null);
352 + await ui.click('بستن و رفتن به تلگرام');
353 + assert.equal(ui.closed, true);
354 + } finally {
355 + await ui.cleanup();
356 + }
357 +});
358 +
359 +test('409 requires an explicit conflict choice and another Save before retrying with the latest revision', async () => {
360 + let writes = 0;
361 + const ui = await setup({
362 + respond(call) {
363 + if (
364 + call.method === 'PUT' &&
365 + call.url.endsWith('/files') &&
366 + ++writes === 1
367 + ) {
368 + return {
369 + status: 409,
370 + body: { ok: false, error: 'نسخه تغییر کرده است.' }
371 + };
372 + }
373 + }
374 + });
375 + try {
376 + await openEditor(ui);
377 + await ui.edit('my unsaved source');
378 + await ui.click('ذخیره تغییرات');
379 + assert.match(ui.dom.window.document.body.textContent, /بارگیری نسخه جدید/);
380 + await ui.click('نگه‌داشتن نسخه من');
381 + assert.equal(writes, 1);
382 + assert.match(
383 + ui.dom.window.document.querySelector('.cm-editor').textContent,
384 + /my unsaved source/
385 + );
386 + await ui.click('ذخیره تغییرات');
387 + assert.equal(writes, 2);
388 + const last = ui.calls
389 + .filter((entry) => entry.method === 'PUT' && entry.url.endsWith('/files'))
390 + .at(-1);
391 + assert.equal(last.headers.get('if-match'), '4');
392 + assert.equal(last.body.text, 'my unsaved source');
393 + } finally {
394 + await ui.cleanup();
395 + }
396 +});
397 +
398 +test('unsaved navigation needs an explicit discard and server UTF-8 limits disable saving', async () => {
399 + const ui = await setup({
400 + respond(call) {
401 + if (call.url === '/api/v1/studio/workspaces' && call.method === 'POST') {
402 + return {
403 + body: {
404 + ok: true,
405 + workspace: workspace('a'),
406 + limits: { ...limits, maxBytes: 5 }
407 + }
408 + };
409 + }
410 + }
411 + });
412 + try {
413 + await openEditor(ui);
414 + await ui.edit('سلام');
415 + const save = [...ui.dom.window.document.querySelectorAll('button')].find(
416 + (entry) => entry.textContent.includes('ذخیره تغییرات')
417 + );
418 + assert.equal(save.disabled, true);
419 + assert.match(ui.dom.window.document.body.textContent, /سقف/);
420 + await ui.click('بازگشت به فایل‌ها');
421 + assert.ok(ui.dom.window.document.querySelector('[role="dialog"]'));
422 + await ui.click('ادامه ویرایش');
423 + assert.match(
424 + ui.dom.window.document.querySelector('.cm-editor').textContent,
425 + /سلام/
426 + );
427 + assert.equal(ui.calls.filter((entry) => entry.method === 'PUT').length, 0);
428 + } finally {
429 + await ui.cleanup();
430 + }
431 +});
432 +
433 +test('adding a file keeps unsaved tabs and uses the pinned workspace tree', async () => {
434 + const ui = await setup({
435 + respond(call) {
436 + if (call.url.includes('/tree?') && call.url.includes('workspaceId=')) {
437 + return {
438 + body: {
439 + ok: true,
440 + repository,
441 + path: '',
442 + items: [
443 + {
444 + refId: 'FileRef123',
445 + name: 'index.js',
446 + path: 'index.js',
447 + type: 'file',
448 + size: 3
449 + },
450 + {
451 + refId: 'OtherRef12',
452 + name: 'other.ts',
453 + path: 'other.ts',
454 + type: 'file',
455 + size: 4
456 + }
457 + ]
458 + }
459 + };
460 + }
461 + if (call.url.endsWith('/files') && call.method === 'POST') {
462 + return {
463 + body: {
464 + ok: true,
465 + workspace: {
466 + ...workspace(),
467 + files: [
468 + ...workspace().files,
469 + {
470 + path: 'other.ts',
471 + draftText: 'export const next = 1;',
472 + revision: 0
473 + }
474 + ]
475 + },
476 + limits
477 + }
478 + };
479 + }
480 + }
481 + });
482 + try {
483 + await openEditor(ui);
484 + await ui.edit('const localOnly = true;');
485 + await ui.click('افزودن فایل');
486 + const tree = ui.calls.find((entry) => entry.url.includes('workspaceId='));
487 + assert.equal(
488 + new URL(tree.url, 'https://studio.example').searchParams.get(
489 + 'workspaceId'
490 + ),
491 + 'Abcdef1234'
492 + );
493 + await ui.click('other.ts');
494 + assert.match(
495 + ui.dom.window.document.querySelector('.cm-editor').textContent,
496 + /export const next/
497 + );
498 + await ui.click('index.js');
499 + assert.match(
500 + ui.dom.window.document.querySelector('.cm-editor').textContent,
501 + /const localOnly = true/
502 + );
503 + assert.equal(
504 + ui.dom.window.document.querySelectorAll('[role="tab"]').length,
505 + 2
506 + );
507 + assert.equal(ui.calls.filter((entry) => entry.method === 'PUT').length, 0);
508 + assert.deepEqual(
509 + ui.calls.find(
510 + (entry) => entry.method === 'POST' && entry.url.endsWith('/files')
511 + ).body,
512 + { refId: 'OtherRef12' }
513 + );
514 + } finally {
515 + await ui.cleanup();
516 + }
517 +});
518 +
519 +test('initial provider failure offers a real retry and empty repositories can reload', async () => {
520 + let reads = 0;
521 + const ui = await setup({
522 + respond(call) {
523 + if (call.url === '/api/v1/studio/repos') {
524 + reads += 1;
525 + if (reads === 1)
526 + return {
527 + status: 503,
528 + body: {
529 + ok: false,
530 + error: 'دریافت مخازن انجام نشد. دوباره تلاش کن.'
531 + }
532 + };
533 + if (reads === 2) return { body: { ok: true, repositories: [] } };
534 + }
535 + }
536 + });
537 + try {
538 + assert.match(
539 + ui.dom.window.document.querySelector('[role="alert"]').textContent,
540 + /دریافت مخازن/
541 + );
542 + await ui.click('تلاش دوباره');
543 + assert.match(
544 + ui.dom.window.document.body.textContent,
545 + /مخزنی برای نمایش نیست/
546 + );
547 + await ui.click('دریافت دوباره مخازن');
548 + await ui.click('hello');
549 + assert.equal(reads, 3);
550 + assert.match(ui.dom.window.document.body.textContent, /index.js/);
551 + } finally {
552 + await ui.cleanup();
553 + }
554 +});
555 +
556 +test('loading the latest conflict version discards only by explicit choice without a write', async () => {
557 + const ui = await setup({
558 + respond(call) {
559 + if (call.method === 'PUT' && call.url.endsWith('/files'))
560 + return {
561 + status: 409,
562 + body: { ok: false, error: 'نسخه تغییر کرده است.' }
563 + };
564 + }
565 + });
566 + try {
567 + await openEditor(ui);
568 + await ui.edit('local change');
569 + await ui.click('ذخیره تغییرات');
570 + await ui.click('بارگیری نسخه جدید');
571 + assert.match(
572 + ui.dom.window.document.querySelector('.cm-editor').textContent,
573 + /const remote = true/
574 + );
575 + assert.equal(ui.calls.filter((entry) => entry.method === 'PUT').length, 1);
576 + const save = [...ui.dom.window.document.querySelectorAll('button')].find(
577 + (entry) => entry.textContent.includes('ذخیره تغییرات')
578 + );
579 + assert.equal(save.disabled, true);
580 + } finally {
581 + await ui.cleanup();
582 + }
583 +});
584 +
585 +test('a committed result appears only after an actual workspace refresh confirms it', async () => {
586 + const ui = await setup({
587 + respond(call) {
588 + if (
589 + call.url === '/api/v1/studio/workspaces/Abcdef1234' &&
590 + call.method === 'GET'
591 + ) {
592 + return {
593 + body: {
594 + ok: true,
595 + workspace: {
596 + ...workspace('const answer = 2;', 1),
597 + state: 'COMMITTED',
598 + result: {
599 + commitSha: 'b'.repeat(40),
600 + branch: 'nexa/edit-Abcdef1234'
601 + }
602 + },
603 + limits
604 + }
605 + };
606 + }
607 + }
608 + });
609 + try {
610 + await openEditor(ui);
611 + await ui.edit('const answer = 2;');
612 + await ui.click('ذخیره تغییرات');
613 + await ui.click('بازبینی تغییرات');
614 + await ui.input('پیام Commit', 'Update answer');
615 + await ui.click('درخواست تأیید امن');
616 + assert.equal(ui.dom.window.document.querySelector('.result-link'), null);
617 + await ui.click('بررسی نتیجه');
618 + const result = ui.dom.window.document.querySelector('.result-link');
619 + assert.equal(
620 + result.href,
621 + `https://github.com/owner/hello/commit/${'b'.repeat(40)}`
622 + );
623 + assert.match(ui.dom.window.document.body.textContent, /Commit ثبت شد/);
624 + } finally {
625 + await ui.cleanup();
626 + }
627 +});
628 +
629 +test('Escape dismisses the unsaved navigation dialog and keeps the local draft', async () => {
630 + const ui = await setup();
631 + try {
632 + await openEditor(ui);
633 + await ui.edit('keep this draft');
634 + await ui.click('بازگشت به فایل‌ها');
635 + await act(async () =>
636 + ui.dom.window.document.dispatchEvent(
637 + new ui.dom.window.KeyboardEvent('keydown', {
638 + key: 'Escape',
639 + bubbles: true
640 + })
641 + )
642 + );
643 + assert.equal(
644 + !!ui.dom.window.document.querySelector('[role="dialog"]'),
645 + false
646 + );
647 + assert.match(
648 + ui.dom.window.document.querySelector('.cm-editor').textContent,
649 + /keep this draft/
650 + );
651 + } finally {
652 + await ui.cleanup();
653 + }
654 +});
655 +
656 +test('approval binds the displayed diff even when message response contains a newer unseen file', async () => {
657 + const ui = await setup({
658 + respond(call) {
659 + if (call.url.endsWith('/message')) {
660 + return {
661 + body: {
662 + ok: true,
663 + workspace: {
664 + ...workspace('UNREVIEWED REMOTE CHANGE', 4),
665 + commitMessage: call.body.message
666 + },
667 + limits
668 + }
669 + };
670 + }
671 + if (call.url.endsWith('/approval')) {
672 + return {
673 + status: 409,
674 + body: {
675 + ok: false,
676 + error: 'نسخه فایل تغییر کرده است. آخرین نسخه را باز کنید.'
677 + }
678 + };
679 + }
680 + }
681 + });
682 + try {
683 + await openEditor(ui);
684 + await ui.edit('const answer = 2;');
685 + await ui.click('ذخیره تغییرات');
686 + await ui.click('بازبینی تغییرات');
687 + await ui.input('پیام Commit', 'Update answer');
688 + await ui.click('درخواست تأیید امن');
689 + const requested = ui.calls.find((entry) => entry.url.endsWith('/approval'));
690 + assert.deepEqual(requested.body, {
691 + message: 'Update answer',
692 + review: {
693 + baseHeadSha: 'a'.repeat(40),
694 + files: [{ path: 'index.js', revision: 1 }]
695 + }
696 + });
697 + assert.doesNotMatch(
698 + ui.dom.window.document.body.textContent,
699 + /درخواست تأیید به تلگرام فرستاده شد/
700 + );
701 + const approvalButton = [
702 + ...ui.dom.window.document.querySelectorAll('button')
703 + ].find((entry) => entry.textContent.includes('درخواست تأیید امن'));
704 + assert.equal(approvalButton.disabled, true);
705 + assert.match(
706 + ui.dom.window.document.body.textContent,
707 + /بارگیری و بازبینی تازه/
708 + );
709 + await ui.click('بارگیری و بازبینی تازه');
710 + assert.equal(
711 + ui.calls.filter((entry) => entry.url.endsWith('/approval')).length,
712 + 1
713 + );
714 + assert.equal(
715 + ui.calls.filter((entry) => entry.url.endsWith('/diff')).length,
716 + 2
717 + );
718 + assert.ok(
719 + ui.calls.some(
720 + (entry) =>
721 + entry.url === '/api/v1/studio/workspaces/Abcdef1234' &&
722 + entry.method === 'GET'
723 + )
724 + );
725 + } finally {
726 + await ui.cleanup();
727 + }
728 +});
729 +
730 +function twoFiles(
731 + a = 'original A',
732 + aRevision = 0,
733 + b = 'original B',
734 + bRevision = 0
735 +) {
736 + return {
737 + ...workspace(a, aRevision),
738 + files: [
739 + { path: 'index.js', draftText: a, revision: aRevision },
740 + { path: 'other.ts', draftText: b, revision: bRevision }
741 + ]
742 + };
743 +}
744 +
745 +for (const operation of ['save', 'add', 'resolve']) {
746 + test(`${operation} keeps the unseen file baseline and requires its original revision on the next save`, async () => {
747 + let writes = 0;
748 + const ui = await setup({
749 + respond(call) {
750 + if (call.url === '/api/v1/studio/workspaces' && call.method === 'POST')
751 + return { body: { ok: true, workspace: twoFiles(), limits } };
752 + if (call.url.includes('/tree?') && call.url.includes('workspaceId='))
753 + return {
754 + body: {
755 + ok: true,
756 + path: '',
757 + items: [
758 + {
759 + refId: 'ThirdRef12',
760 + name: 'third.js',
761 + path: 'third.js',
762 + type: 'file',
763 + size: 1
764 + }
765 + ]
766 + }
767 + };
768 + if (call.url.endsWith('/files') && call.method === 'POST')
769 + return {
770 + body: {
771 + ok: true,
772 + workspace: {
773 + ...twoFiles('original A', 0, 'unseen remote B', 7),
774 + files: [
775 + ...twoFiles('original A', 0, 'unseen remote B', 7).files,
776 + { path: 'third.js', draftText: 'third', revision: 0 }
777 + ]
778 + },
779 + limits
780 + }
781 + };
782 + if (call.url.endsWith('/files') && call.method === 'PUT') {
783 + writes += 1;
784 + if (operation === 'resolve' && writes === 1)
785 + return {
786 + status: 409,
787 + body: { ok: false, error: 'نسخه تغییر کرده است.' }
788 + };
789 + if (call.body.path === 'other.ts')
790 + return {
791 + status: 409,
792 + body: { ok: false, error: 'نسخه تغییر کرده است.' }
793 + };
794 + return {
795 + body: {
796 + ok: true,
797 + workspace: twoFiles(call.body.text, 1, 'unseen remote B', 7),
798 + limits
799 + }
800 + };
801 + }
802 + if (call.url === '/api/v1/studio/workspaces/Abcdef1234')
803 + return {
804 + body: {
805 + ok: true,
806 + workspace: twoFiles('remote A', 3, 'unseen remote B', 7),
807 + limits
808 + }
809 + };
810 + }
811 + });
812 + try {
813 + await openEditor(ui);
814 + if (operation === 'add') {
815 + await ui.click('افزودن فایل');
816 + await ui.click('third.js');
817 + } else {
818 + await ui.edit('local A');
819 + await ui.click('ذخیره تغییرات');
820 + if (operation === 'resolve') await ui.click('نگه‌داشتن نسخه من');
821 + }
822 + await ui.click('other.ts');
823 + assert.match(
824 + ui.dom.window.document.querySelector('.cm-editor').textContent,
825 + /original B/
826 + );
827 + await ui.edit('my B change');
828 + await ui.click('ذخیره تغییرات');
829 + const saveB = ui.calls.find(
830 + (call) => call.method === 'PUT' && call.body.path === 'other.ts'
831 + );
832 + assert.equal(
833 + saveB.headers.get('if-match'),
834 + '0',
835 + 'Never silently adopt an unseen remote revision'
836 + );
837 + assert.match(
838 + ui.dom.window.document.body.textContent,
839 + /بارگیری نسخه جدید/
840 + );
841 + } finally {
842 + await ui.cleanup();
843 + }
844 + });
845 +}
846 +
847 +test('approval compares the exact displayed message when another session changes only the message', async () => {
848 + const ui = await setup({
849 + respond(call) {
850 + if (call.url.endsWith('/message'))
851 + return {
852 + body: {
853 + ok: true,
854 + workspace: {
855 + ...workspace('const answer = 2;', 1),
856 + commitMessage: 'unseen remote message'
857 + },
858 + limits
859 + }
860 + };
861 + if (call.url.endsWith('/approval'))
862 + return {
863 + status: 409,
864 + body: {
865 + ok: false,
866 + error: 'پیام تغییر کرده است. دوباره بازبینی کنید.'
867 + }
868 + };
869 + }
870 + });
871 + try {
872 + await openEditor(ui);
873 + await ui.edit('const answer = 2;');
874 + await ui.click('ذخیره تغییرات');
875 + await ui.click('بازبینی تغییرات');
876 + await ui.input('پیام Commit', ' My reviewed message ');
877 + await ui.click('درخواست تأیید امن');
878 + const request = ui.calls.find((call) => call.url.endsWith('/approval'));
879 + assert.equal(request.body.message, 'My reviewed message');
880 + assert.deepEqual(request.body.review.files, [
881 + { path: 'index.js', revision: 1 }
882 + ]);
883 + assert.equal(
884 + ui.dom.window.document.querySelector('[aria-label="پیام Commit"]').value,
885 + ' My reviewed message '
886 + );
887 + assert.doesNotMatch(
888 + ui.dom.window.document.body.textContent,
889 + /درخواست تأیید به تلگرام فرستاده شد/
890 + );
891 + assert.match(
892 + ui.dom.window.document.body.textContent,
893 + /بارگیری و بازبینی تازه/
894 + );
895 + } finally {
896 + await ui.cleanup();
897 + }
898 +});
899 +
900 +test('remount restores only the opaque handle and continues with fresh server draft content', async () => {
901 + const ui = await setup();
902 + try {
903 + await openEditor(ui);
904 + await ui.edit('unsaved source must disappear');
905 + assert.deepEqual(Object.entries(ui.dom.window.localStorage), [
906 + ['nexa.studio.workspace', 'Abcdef1234']
907 + ]);
908 + await ui.remount();
909 + assert.equal(ui.dom.window.document.querySelector('.cm-editor'), null);
910 + assert.ok(
911 + ui.calls.some(
912 + (call) =>
913 + call.url.endsWith('/workspaces/Abcdef1234') && call.method === 'GET'
914 + )
915 + );
916 + await ui.click('ادامه فضای کاری');
917 + assert.match(
918 + ui.dom.window.document.querySelector('.cm-editor').textContent,
919 + /const remote = true/
920 + );
921 + assert.doesNotMatch(
922 + ui.dom.window.document.body.textContent,
923 + /unsaved source must disappear/
924 + );
925 + } finally {
926 + await ui.cleanup();
927 + }
928 +});
929 +
930 +for (const state of ['READY', 'COMMITTED']) {
931 + test(`remounted ${state} workspace uses fresh evidence before review or a committed result`, async () => {
932 + let resumed = false;
933 + const ui = await setup({
934 + respond(call) {
935 + if (resumed && call.url === '/api/v1/studio/workspaces/Abcdef1234')
936 + return {
937 + body: {
938 + ok: true,
939 + workspace: {
940 + ...workspace('const answer = 2;', 1),
941 + state,
942 + commitMessage: 'Saved message',
943 + ...(state === 'COMMITTED'
944 + ? {
945 + result: {
946 + commitSha: 'b'.repeat(40),
947 + branch: 'nexa/edit-Abcdef1234'
948 + }
949 + }
950 + : {})
951 + },
952 + limits
953 + }
954 + };
955 + }
956 + });
957 + try {
958 + await openEditor(ui);
959 + await ui.edit('const answer = 2;');
960 + await ui.click('ذخیره تغییرات');
961 + await ui.click('بازبینی تغییرات');
962 + await ui.input('پیام Commit', 'Saved message');
963 + await ui.click('درخواست تأیید امن');
964 + await ui.click('بستن و رفتن به تلگرام');
965 + resumed = true;
966 + await ui.remount();
967 + assert.equal(ui.dom.window.document.querySelector('.result-link'), null);
968 + assert.doesNotMatch(
969 + ui.dom.window.document.body.textContent,
970 + /درخواست تأیید به تلگرام فرستاده شد/
971 + );
972 + const approvals = ui.calls.filter((call) =>
973 + call.url.endsWith('/approval')
974 + ).length;
975 + const diffs = ui.calls.filter((call) =>
976 + call.url.endsWith('/diff')
977 + ).length;
978 + await ui.click('ادامه فضای کاری');
979 + assert.equal(
980 + ui.calls.filter((call) => call.url.endsWith('/approval')).length,
981 + approvals
982 + );
983 + if (state === 'COMMITTED') {
984 + assert.equal(
985 + ui.dom.window.document.querySelector('.result-link').href,
986 + `https://github.com/owner/hello/commit/${'b'.repeat(40)}`
987 + );
988 + } else {
989 + assert.equal(
990 + ui.calls.filter((call) => call.url.endsWith('/diff')).length,
991 + diffs + 1
992 + );
993 + assert.equal(
994 + ui.dom.window.document.querySelector('[aria-label="پیام Commit"]')
995 + .value,
996 + 'Saved message'
997 + );
998 + assert.doesNotMatch(
999 + ui.dom.window.document.body.textContent,
1000 + /درخواست تأیید به تلگرام فرستاده شد/
1001 + );
1002 + await ui.click('بازگشت به ویرایشگر');
1003 + await ui.click('بازبینی تغییرات');
1004 + await ui.click('درخواست تأیید امن');
1005 + assert.equal(
1006 + ui.calls.filter((call) => call.url.endsWith('/approval')).length,
1007 + approvals + 1
1008 + );
1009 + }
1010 + } finally {
1011 + await ui.cleanup();
1012 + }
1013 + });
1014 +}
1015 +
1016 +for (const mode of ['invalid', 'expired', 'forbidden', 'nonowner', 'outside']) {
1017 + test(`stored workspace recovery handles ${mode} without retaining an invalid session`, async () => {
1018 + const ui = await setup({
1019 + telegram: mode !== 'outside',
1020 + stored: {
1021 + 'nexa.studio.workspace':
1022 + mode === 'invalid' ? 'not/a/handle' : 'Abcdef1234'
1023 + },
1024 + respond(call) {
1025 + if (mode === 'nonowner' && call.url === '/api/v1/studio')
1026 + return {
1027 + status: 403,
1028 + body: { ok: false, error: 'دسترسی مجاز نیست.' }
1029 + };
1030 + if (
1031 + ['expired', 'forbidden'].includes(mode) &&
1032 + call.url.endsWith('/workspaces/Abcdef1234')
1033 + )
1034 + return {
1035 + status: mode === 'expired' ? 404 : 403,
1036 + body: { ok: false, error: 'فضای کار منقضی شده است.' }
1037 + };
1038 + }
1039 + });
1040 + try {
1041 + if (mode === 'outside') assert.equal(ui.calls.length, 0);
1042 + else
1043 + assert.equal(
1044 + ui.dom.window.localStorage.getItem('nexa.studio.workspace'),
1045 + null
1046 + );
1047 + if (mode === 'nonowner' || mode === 'invalid')
1048 + assert.equal(
1049 + ui.calls.some((call) => call.url.includes('/workspaces/')),
1050 + false
1051 + );
1052 + assert.doesNotMatch(
1053 + ui.dom.window.document.body.textContent,
1054 + /ادامه فضای کاری/
1055 + );
1056 + } finally {
1057 + await ui.cleanup();
1058 + }
1059 + });
1060 +}
1061 +
1062 +test('cancel clears the saved handle and unavailable local storage never breaks editing', async () => {
1063 + for (const storageUnavailable of [false, true]) {
1064 + const ui = await setup({
1065 + storageUnavailable,
1066 + respond(call) {
1067 + if (call.method === 'DELETE')
1068 + return { body: { ok: true, cancelled: true } };
1069 + }
1070 + });
1071 + try {
1072 + await openEditor(ui);
1073 + await ui.edit('a real edit');
1074 + await ui.click('ذخیره تغییرات');
1075 + await ui.click('لغو فضای کاری');
1076 + await ui.click('کنار گذاشتن و ادامه');
1077 + assert.equal(
1078 + ui.calls.filter((call) => call.method === 'DELETE').length,
1079 + 1
1080 + );
1081 + assert.doesNotMatch(
1082 + ui.dom.window.document.body.textContent,
1083 + /ادامه فضای کاری/
1084 + );
1085 + if (!storageUnavailable)
1086 + assert.equal(
1087 + ui.dom.window.localStorage.getItem('nexa.studio.workspace'),
1088 + null
1089 + );
1090 + } finally {
1091 + await ui.cleanup();
1092 + }
1093 + }
1094 +});
1095 +
1096 +test('a temporary recovery failure keeps the handle and retries against the server', async () => {
1097 + let reads = 0;
1098 + const ui = await setup({
1099 + stored: { 'nexa.studio.workspace': 'Abcdef1234' },
1100 + respond(call) {
1101 + if (call.url.endsWith('/workspaces/Abcdef1234') && ++reads === 1)
1102 + return {
1103 + status: 503,
1104 + body: { ok: false, error: 'سرویس موقتاً در دسترس نیست.' }
1105 + };
1106 + }
1107 + });
1108 + try {
1109 + assert.equal(
1110 + ui.dom.window.localStorage.getItem('nexa.studio.workspace'),
1111 + 'Abcdef1234'
1112 + );
1113 + assert.match(
1114 + ui.dom.window.document.querySelector('[role="alert"]').textContent,
1115 + /موقتاً/
1116 + );
1117 + await ui.click('تلاش دوباره');
1118 + await ui.click('ادامه فضای کاری');
1119 + assert.equal(reads, 3);
1120 + assert.match(
1121 + ui.dom.window.document.querySelector('.cm-editor').textContent,
1122 + /const remote = true/
1123 + );
1124 + } finally {
1125 + await ui.cleanup();
1126 + }
1127 +});
test/studio-revision.test.js new
+831
@@ -0,0 +1,831 @@
1 +import test from 'node:test';
2 +import assert from 'node:assert/strict';
3 +import { DurableWorkspaceStoreClient } from '../src/core/workspace-store.js';
4 +import { WorkspaceStore } from '../src/durable/workspace-store.js';
5 +
6 +function makeState() {
7 + const data = new Map();
8 + let transactionTail = Promise.resolve();
9 + const api = {
10 + async get(key) {
11 + return structuredClone(data.get(key));
12 + },
13 + async put(key, value) {
14 + data.set(key, structuredClone(value));
15 + },
16 + async delete(key) {
17 + return data.delete(key);
18 + }
19 + };
20 + return {
21 + data,
22 + storage: {
23 + ...api,
24 + transaction(fn) {
25 + const result = transactionTail.then(() => fn(api));
26 + transactionTail = result.catch(() => {});
27 + return result;
28 + },
29 + async setAlarm() {}
30 + }
31 + };
32 +}
33 +
34 +function fixture() {
35 + const states = new Map();
36 + const namespace = {
37 + idFromName: String,
38 + get(id) {
39 + if (!states.has(id)) states.set(id, makeState());
40 + const store = new WorkspaceStore(states.get(id));
41 + return { fetch: (request) => store.fetch(request) };
42 + }
43 + };
44 + const client = new DurableWorkspaceStoreClient({
45 + namespace,
46 + now: () => 1000
47 + });
48 + return { client, states };
49 +}
50 +
51 +const initial = {
52 + ownerId: 'A',
53 + repoId: 123,
54 + repoFullName: 'owner/repo',
55 + baseBranch: 'main',
56 + baseHeadSha: 'a'.repeat(40),
57 + baseTreeSha: 'b'.repeat(40),
58 + path: 'a.txt',
59 + blobSha: 'c'.repeat(40),
60 + originalText: 'before\n',
61 + originalDigest: 'd'.repeat(64)
62 +};
63 +
64 +const edit = (workspaceId, overrides = {}) => ({
65 + ownerId: 'A',
66 + workspaceId,
67 + path: 'a.txt',
68 + text: 'after\n',
69 + digest: 'e'.repeat(64),
70 + expectedRevision: 0,
71 + ...overrides
72 +});
73 +
74 +const isConflict = (error) => {
75 + assert.equal(error.status, 409);
76 + assert.equal(error.code, 'REVISION_CONFLICT');
77 + assert.equal(error.message.includes('PRIVATE_DRAFT_SENTINEL'), false);
78 + return true;
79 +};
80 +
81 +test('per-file revisions start at zero and successful conditional edits advance them', async () => {
82 + const { client } = fixture();
83 + let workspace = await client.createWorkspace(initial);
84 + assert.equal(workspace.files[0].revision, 0);
85 + workspace = await client.updateWorkspaceFileDraft(edit(workspace.id));
86 + assert.equal(workspace.files[0].revision, 1);
87 + assert.equal(workspace.files[0].draftText, 'after\n');
88 + workspace = await client.updateWorkspaceFileDraft(
89 + edit(workspace.id, {
90 + expectedRevision: 1,
91 + text: 'next\n',
92 + digest: 'f'.repeat(64)
93 + })
94 + );
95 + assert.equal(workspace.files[0].revision, 2);
96 +});
97 +
98 +test('stale revisions return a typed conflict without changing workspace or READY intent', async () => {
99 + const { client, states } = fixture();
100 + const workspace = await client.createWorkspace(initial);
101 + await client.updateWorkspaceFileDraft(edit(workspace.id));
102 + await client.sealIntent({
103 + ownerId: 'A',
104 + workspaceId: workspace.id,
105 + intent: { intentDigest: '1'.repeat(64) }
106 + });
107 + await client.setPendingInput({
108 + ownerId: 'A',
109 + workspaceId: workspace.id,
110 + mode: 'draft_file'
111 + });
112 + const before = structuredClone(states.get('A').data);
113 + await assert.rejects(
114 + client.updateWorkspaceFileDraft(
115 + edit(workspace.id, {
116 + text: 'PRIVATE_DRAFT_SENTINEL',
117 + digest: 'f'.repeat(64)
118 + })
119 + ),
120 + isConflict
121 + );
122 + assert.deepEqual(states.get('A').data, before);
123 +});
124 +
125 +test('a same-file concurrent If-Match update has exactly one winner', async () => {
126 + const { client } = fixture();
127 + const workspace = await client.createWorkspace(initial);
128 + const outcomes = await Promise.allSettled([
129 + client.updateWorkspaceFileDraft(edit(workspace.id)),
130 + client.updateWorkspaceFileDraft(
131 + edit(workspace.id, { text: 'second\n', digest: 'f'.repeat(64) })
132 + )
133 + ]);
134 + assert.equal(outcomes.filter((r) => r.status === 'fulfilled').length, 1);
135 + const rejected = outcomes.find((r) => r.status === 'rejected');
136 + isConflict(rejected.reason);
137 + const stored = await client.getWorkspace({
138 + ownerId: 'A',
139 + workspaceId: workspace.id
140 + });
141 + assert.equal(stored.files[0].revision, 1);
142 + assert.equal(
143 + stored.files[0].draftText,
144 + outcomes.find((r) => r.status === 'fulfilled').value.files[0].draftText
145 + );
146 +});
147 +
148 +test('concurrent edits of different files preserve both edits and independent revisions', async () => {
149 + const { client } = fixture();
150 + let workspace = await client.createWorkspace(initial);
151 + workspace = await client.upsertWorkspaceFile({
152 + ownerId: 'A',
153 + workspaceId: workspace.id,
154 + file: { ...initial, path: 'b.txt' }
155 + });
156 + assert.equal(workspace.files[1].revision, 0);
157 + await Promise.all([
158 + client.updateWorkspaceFileDraft(edit(workspace.id)),
159 + client.updateWorkspaceFileDraft(
160 + edit(workspace.id, {
161 + path: 'b.txt',
162 + text: 'second\n',
163 + digest: 'f'.repeat(64)
164 + })
165 + )
166 + ]);
167 + const stored = await client.getWorkspace({
168 + ownerId: 'A',
169 + workspaceId: workspace.id
170 + });
171 + assert.deepEqual(
172 + stored.files.map(({ path, draftText, revision }) => ({
173 + path,
174 + draftText,
175 + revision
176 + })),
177 + [
178 + { path: 'a.txt', draftText: 'after\n', revision: 1 },
179 + { path: 'b.txt', draftText: 'second\n', revision: 1 }
180 + ]
181 + );
182 +});
183 +
184 +test('a concurrent commit-message write cannot restore an earlier file draft', async () => {
185 + const { client } = fixture();
186 + const workspace = await client.createWorkspace(initial);
187 + await Promise.all([
188 + client.updateWorkspaceFileDraft(edit(workspace.id)),
189 + client.setCommitMessage({
190 + ownerId: 'A',
191 + workspaceId: workspace.id,
192 + message: 'Update file',
193 + digest: '1'.repeat(64)
194 + })
195 + ]);
196 + const stored = await client.getWorkspace({
197 + ownerId: 'A',
198 + workspaceId: workspace.id
199 + });
200 + assert.equal(stored.files[0].draftText, 'after\n');
201 + assert.equal(stored.files[0].revision, 1);
202 + assert.equal(stored.commitMessage, 'Update file');
203 +});
204 +
205 +test('concurrent intent sealing cannot restore an earlier file draft', async () => {
206 + const { client } = fixture();
207 + const workspace = await client.createWorkspace(initial);
208 + await Promise.all([
209 + client.updateWorkspaceFileDraft(edit(workspace.id)),
210 + client.sealIntent({
211 + ownerId: 'A',
212 + workspaceId: workspace.id,
213 + intent: { intentDigest: '1'.repeat(64) }
214 + })
215 + ]);
216 + const stored = await client.getWorkspace({
217 + ownerId: 'A',
218 + workspaceId: workspace.id
219 + });
220 + assert.equal(stored.files[0].draftText, 'after\n');
221 + assert.equal(stored.files[0].revision, 1);
222 +});
223 +
224 +test('legacy edits without expectedRevision still invalidate stale conditional edits', async () => {
225 + const { client } = fixture();
226 + let workspace = await client.createWorkspace(initial);
227 + workspace = await client.updateWorkspaceFileDraft(
228 + edit(workspace.id, { expectedRevision: undefined })
229 + );
230 + assert.equal(workspace.files[0].revision, 1);
231 + await assert.rejects(
232 + client.updateWorkspaceFileDraft(edit(workspace.id)),
233 + isConflict
234 + );
235 + workspace = await client.updateDraft({
236 + ownerId: 'A',
237 + workspaceId: workspace.id,
238 + text: 'legacy\n',
239 + digest: 'f'.repeat(64)
240 + });
241 + assert.equal(workspace.files[0].revision, 2);
242 + await assert.rejects(
243 + client.updateWorkspaceFileDraft(
244 + edit(workspace.id, { expectedRevision: 1 })
245 + ),
246 + isConflict
247 + );
248 +});
249 +
250 +test('identical draft calls advance revisions while preserving an identical READY intent', async () => {
251 + const { client } = fixture();
252 + const workspace = await client.createWorkspace(initial);
253 + const intent = await client.sealIntent({
254 + ownerId: 'A',
255 + workspaceId: workspace.id,
256 + intent: { intentDigest: '1'.repeat(64) }
257 + });
258 + let updated = await client.updateWorkspaceFileDraft(
259 + edit(workspace.id, {
260 + text: initial.originalText,
261 + digest: initial.originalDigest
262 + })
263 + );
264 + assert.equal(updated.files[0].revision, 1);
265 + assert.equal(updated.currentIntentId, intent.id);
266 + assert.equal(updated.state, 'READY');
267 + updated = await client.updateDraft({
268 + ownerId: 'A',
269 + workspaceId: workspace.id,
270 + text: initial.originalText,
271 + digest: initial.originalDigest
272 + });
273 + assert.equal(updated.files[0].revision, 2);
274 + assert.equal(updated.currentIntentId, intent.id);
275 + updated = await client.updateWorkspaceFileDraft(
276 + edit(workspace.id, { expectedRevision: 2 })
277 + );
278 + assert.equal(updated.currentIntentId, null);
279 + assert.equal(updated.state, 'DRAFT');
280 +});
281 +
282 +test('pre-revision multi-file and legacy records read as zero and accept the first conditional write', async () => {
283 + for (const legacy of [false, true]) {
284 + const { client, states } = fixture();
285 + const workspace = await client.createWorkspace(initial);
286 + const stored = structuredClone(
287 + states.get('A').data.get(`ws:${workspace.id}`)
288 + );
289 + delete stored.files[0].revision;
290 + if (legacy) delete stored.files;
291 + states.get('A').data.set(`ws:${workspace.id}`, stored);
292 + const loaded = await client.getWorkspace({
293 + ownerId: 'A',
294 + workspaceId: workspace.id
295 + });
296 + assert.equal(loaded.files[0].revision, 0);
297 + const updated = await client.updateWorkspaceFileDraft(edit(workspace.id));
298 + assert.equal(updated.files[0].revision, 1);
299 + }
300 +});
301 +
302 +test('removing and readding a path cannot revive an old revision', async () => {
303 + const { client } = fixture();
304 + let workspace = await client.createWorkspace(initial);
305 + workspace = await client.upsertWorkspaceFile({
306 + ownerId: 'A',
307 + workspaceId: workspace.id,
308 + file: { ...initial, path: 'b.txt' }
309 + });
310 + await client.updateWorkspaceFileDraft(edit(workspace.id));
311 + await client.removeWorkspaceFile({
312 + ownerId: 'A',
313 + workspaceId: workspace.id,
314 + path: 'a.txt'
315 + });
316 + workspace = await client.upsertWorkspaceFile({
317 + ownerId: 'A',
318 + workspaceId: workspace.id,
319 + file: initial
320 + });
321 + assert.equal(workspace.files[0].revision, 0);
322 + assert.equal(workspace.files[1].revision, 2);
323 + for (const expectedRevision of [0, 1]) {
324 + await assert.rejects(
325 + client.updateWorkspaceFileDraft(edit(workspace.id, { expectedRevision })),
326 + isConflict
327 + );
328 + }
329 + workspace = await client.updateWorkspaceFileDraft(
330 + edit(workspace.id, { expectedRevision: 2 })
331 + );
332 + assert.equal(workspace.files[1].revision, 3);
333 +});
334 +
335 +test('foreign-owner conditional updates have no effect on the owner workspace', async () => {
336 + const { client, states } = fixture();
337 + const workspace = await client.createWorkspace(initial);
338 + const before = structuredClone(states.get('A').data);
339 + await assert.rejects(
340 + client.updateWorkspaceFileDraft(edit(workspace.id, { ownerId: 'B' })),
341 + /not found or expired/i
342 + );
343 + assert.deepEqual(states.get('A').data, before);
344 + assert.equal(
345 + await client.getWorkspace({ ownerId: 'B', workspaceId: workspace.id }),
346 + null
347 + );
348 +});
349 +
350 +test('invalid expected revisions cannot disable optimistic concurrency', async () => {
351 + const { client, states } = fixture();
352 + const workspace = await client.createWorkspace(initial);
353 + const before = structuredClone(states.get('A').data);
354 + for (const expectedRevision of [
355 + null,
356 + '',
357 + '0',
358 + -1,
359 + 0.5,
360 + Number.MAX_SAFE_INTEGER + 1
361 + ]) {
362 + await assert.rejects(
363 + client.updateWorkspaceFileDraft(edit(workspace.id, { expectedRevision })),
364 + /revision.*invalid/i
365 + );
366 + }
367 + assert.deepEqual(states.get('A').data, before);
368 +});
369 +
370 +const materialMutations = (client, workspaceId) => [
371 + () => client.updateWorkspaceFileDraft(edit(workspaceId)),
372 + () =>
373 + client.updateDraft({
374 + ownerId: 'A',
375 + workspaceId,
376 + text: 'legacy\n',
377 + digest: 'f'.repeat(64)
378 + }),
379 + () =>
380 + client.upsertWorkspaceFile({
381 + ownerId: 'A',
382 + workspaceId,
383 + file: { ...initial, path: 'c.txt' }
384 + }),
385 + () =>
386 + client.removeWorkspaceFile({ ownerId: 'A', workspaceId, path: 'b.txt' }),
387 + () =>
388 + client.setCommitMessage({
389 + ownerId: 'A',
390 + workspaceId,
391 + message: 'Late message',
392 + digest: 'f'.repeat(64)
393 + }),
394 + () =>
395 + client.sealIntent({
396 + ownerId: 'A',
397 + workspaceId,
398 + intent: { intentDigest: 'f'.repeat(64) }
399 + })
400 +];
401 +
402 +test('writes queued behind beginCommit cannot reset an in-flight workspace', async () => {
403 + const { client, states } = fixture();
404 + let workspace = await client.createWorkspace(initial);
405 + workspace = await client.upsertWorkspaceFile({
406 + ownerId: 'A',
407 + workspaceId: workspace.id,
408 + file: { ...initial, path: 'b.txt' }
409 + });
410 + const intent = await client.sealIntent({
411 + ownerId: 'A',
412 + workspaceId: workspace.id,
413 + intent: { intentDigest: '1'.repeat(64) }
414 + });
415 + const operations = materialMutations(client, workspace.id);
416 + const [started, ...outcomes] = await Promise.allSettled([
417 + client.beginCommit({ ownerId: 'A', intentId: intent.id }),
418 + ...operations.map((operation) => operation())
419 + ]);
420 + assert.equal(started.status, 'fulfilled');
421 + assert.equal(started.value.disposition, 'start');
422 + for (const outcome of outcomes) {
423 + assert.equal(outcome.status, 'rejected');
424 + assert.equal(outcome.reason.status, 409);
425 + assert.equal(outcome.reason.code, 'WORKSPACE_NOT_EDITABLE');
426 + }
427 + const stored = await client.getWorkspace({
428 + ownerId: 'A',
429 + workspaceId: workspace.id
430 + });
431 + assert.equal(stored.files[0].draftText, 'before\n');
432 + assert.equal(stored.files[0].revision, 0);
433 + assert.equal(stored.files.length, 2);
434 + assert.equal(stored.commitMessage, '');
435 + assert.equal(stored.currentIntentId, intent.id);
436 + assert.equal(
437 + states.get('A').data.get(`intent:${intent.id}`).state,
438 + 'COMMITTING'
439 + );
440 +});
441 +
442 +test('committed workspace material and message cannot be changed by a delayed write', async () => {
443 + const { client, states } = fixture();
444 + let workspace = await client.createWorkspace(initial);
445 + workspace = await client.upsertWorkspaceFile({
446 + ownerId: 'A',
447 + workspaceId: workspace.id,
448 + file: { ...initial, path: 'b.txt' }
449 + });
450 + const intent = await client.sealIntent({
451 + ownerId: 'A',
452 + workspaceId: workspace.id,
453 + intent: { intentDigest: '1'.repeat(64) }
454 + });
455 + await client.beginCommit({ ownerId: 'A', intentId: intent.id });
456 + await client.completeCommit({
457 + ownerId: 'A',
458 + intentId: intent.id,
459 + commitSha: 'e'.repeat(40),
460 + branch: `nexa/edit-${workspace.id}`
461 + });
462 + const before = structuredClone(states.get('A').data);
463 + for (const operation of materialMutations(client, workspace.id)) {
464 + await assert.rejects(operation(), (error) => {
465 + assert.equal(error.status, 409);
466 + assert.equal(error.code, 'WORKSPACE_NOT_EDITABLE');
467 + return true;
468 + });
469 + }
470 + assert.deepEqual(states.get('A').data, before);
471 +});
472 +
473 +test('concurrent file additions cannot exceed the eight-file workspace limit', async () => {
474 + const { client } = fixture();
475 + let workspace = await client.createWorkspace(initial);
476 + for (let index = 1; index < 7; index++) {
477 + workspace = await client.upsertWorkspaceFile({
478 + ownerId: 'A',
479 + workspaceId: workspace.id,
480 + file: { ...initial, path: `${index}.txt` }
481 + });
482 + }
483 + const outcomes = await Promise.allSettled(
484 + ['last.txt', 'excess.txt'].map((path) =>
485 + client.upsertWorkspaceFile({
486 + ownerId: 'A',
487 + workspaceId: workspace.id,
488 + file: { ...initial, path }
489 + })
490 + )
491 + );
492 + assert.equal(
493 + outcomes.filter((outcome) => outcome.status === 'fulfilled').length,
494 + 1
495 + );
496 + const failure = outcomes.find((outcome) => outcome.status === 'rejected');
497 + assert.equal(failure.reason.status, 422);
498 + assert.equal(failure.reason.code, 'WORKSPACE_LIMIT_EXCEEDED');
499 + const stored = await client.getWorkspace({
500 + ownerId: 'A',
501 + workspaceId: workspace.id
502 + });
503 + assert.equal(stored.files.length, 8);
504 +});
505 +
506 +test('concurrent different-file edits enforce the UTF-8 aggregate boundary atomically', async () => {
507 + const { client } = fixture();
508 + const large = '😀'.repeat(10000);
509 + let workspace = await client.createWorkspace({
510 + ...initial,
511 + originalText: large
512 + });
513 + for (const path of ['b.txt', 'c.txt']) {
514 + workspace = await client.upsertWorkspaceFile({
515 + ownerId: 'A',
516 + workspaceId: workspace.id,
517 + file: { ...initial, path, originalText: large }
518 + });
519 + }
520 + const outcomes = await Promise.allSettled(
521 + ['a.txt', 'b.txt'].map((path) =>
522 + client.updateWorkspaceFileDraft(
523 + edit(workspace.id, { path, text: large + 'x'.repeat(6000) })
524 + )
525 + )
526 + );
527 + assert.equal(
528 + outcomes.filter((outcome) => outcome.status === 'fulfilled').length,
529 + 1
530 + );
531 + const failure = outcomes.find((outcome) => outcome.status === 'rejected');
532 + assert.equal(failure.reason.status, 422);
533 + assert.equal(failure.reason.code, 'WORKSPACE_LIMIT_EXCEEDED');
534 + const stored = await client.getWorkspace({
535 + ownerId: 'A',
536 + workspaceId: workspace.id
537 + });
538 + assert.equal(
539 + stored.files.reduce(
540 + (total, file) =>
541 + total + new TextEncoder().encode(file.draftText).byteLength,
542 + 0
543 + ),
544 + 126000
545 + );
546 + assert.deepEqual(stored.files.map((file) => file.revision).sort(), [0, 0, 1]);
547 +});
548 +
549 +test('workspace aggregate policy retains original text when an edited draft shrinks', async () => {
550 + const { client, states } = fixture();
551 + const large = '😀'.repeat(15000);
552 + let workspace = await client.createWorkspace({
553 + ...initial,
554 + originalText: large
555 + });
556 + workspace = await client.upsertWorkspaceFile({
557 + ownerId: 'A',
558 + workspaceId: workspace.id,
559 + file: { ...initial, path: 'b.txt', originalText: large }
560 + });
561 + await client.updateWorkspaceFileDraft(edit(workspace.id, { text: '' }));
562 + await client.updateWorkspaceFileDraft(
563 + edit(workspace.id, { path: 'b.txt', text: '' })
564 + );
565 + const before = structuredClone(states.get('A').data);
566 + await assert.rejects(
567 + client.upsertWorkspaceFile({
568 + ownerId: 'A',
569 + workspaceId: workspace.id,
570 + file: { ...initial, path: 'c.txt', originalText: 'x'.repeat(11073) }
571 + }),
572 + (error) => {
573 + assert.equal(error.status, 422);
574 + assert.equal(error.code, 'WORKSPACE_LIMIT_EXCEEDED');
575 + return true;
576 + }
577 + );
578 + assert.deepEqual(states.get('A').data, before);
579 +});
580 +
581 +const reviewOf = (workspace) => ({
582 + baseHeadSha: workspace.baseHeadSha,
583 + files: workspace.files.map(({ path, revision }) => ({ path, revision }))
584 +});
585 +
586 +const reviewedIntent = (workspaceId, overrides = {}) => ({
587 + workspaceId,
588 + repoId: 123,
589 + baseBranch: 'main',
590 + baseHeadSha: 'a'.repeat(40),
591 + baseTreeSha: 'b'.repeat(40),
592 + files: [
593 + {
594 + path: 'a.txt',
595 + sourceBlobSha: 'c'.repeat(40),
596 + contentDigest: 'd'.repeat(64)
597 + }
598 + ],
599 + commitMessageDigest: '1'.repeat(64),
600 + intentDigest: '2'.repeat(64),
601 + ...overrides
602 +});
603 +
604 +test('a message change queued before sealing rejects its displayed digest atomically', async () => {
605 + const { client, states } = fixture();
606 + const workspace = await client.createWorkspace(initial);
607 + await client.setCommitMessage({
608 + ownerId: 'A',
609 + workspaceId: workspace.id,
610 + message: 'Reviewed message',
611 + digest: '1'.repeat(64)
612 + });
613 + const [saved, sealed] = await Promise.allSettled([
614 + client.setCommitMessage({
615 + ownerId: 'A',
616 + workspaceId: workspace.id,
617 + message: 'Unreviewed message',
618 + digest: '2'.repeat(64)
619 + }),
620 + client.sealIntent({
621 + ownerId: 'A',
622 + workspaceId: workspace.id,
623 + intent: reviewedIntent(workspace.id),
624 + expectedReview: {
625 + ...reviewOf(workspace),
626 + commitMessageDigest: '1'.repeat(64)
627 + }
628 + })
629 + ]);
630 + assert.equal(saved.status, 'fulfilled');
631 + assert.equal(sealed.status, 'rejected');
632 + isConflict(sealed.reason);
633 + const stored = await client.getWorkspace({
634 + ownerId: 'A',
635 + workspaceId: workspace.id
636 + });
637 + assert.equal(stored.commitMessage, 'Unreviewed message');
638 + assert.equal(stored.currentIntentId, null);
639 + assert.equal(stored.state, 'DRAFT');
640 + assert.equal(
641 + [...states.get('A').data.keys()].some((key) => key.startsWith('intent:')),
642 + false
643 + );
644 +});
645 +
646 +test('sealing accepts a matching displayed message digest and preserves legacy review callers', async () => {
647 + const { client } = fixture();
648 + const workspace = await client.createWorkspace(initial);
649 + await client.setCommitMessage({
650 + ownerId: 'A',
651 + workspaceId: workspace.id,
652 + message: 'Reviewed message',
653 + digest: '1'.repeat(64)
654 + });
655 + const sealed = await client.sealIntent({
656 + ownerId: 'A',
657 + workspaceId: workspace.id,
658 + intent: reviewedIntent(workspace.id),
659 + expectedReview: {
660 + ...reviewOf(workspace),
661 + commitMessageDigest: '1'.repeat(64)
662 + }
663 + });
664 + const repeated = await client.sealIntent({
665 + ownerId: 'A',
666 + workspaceId: workspace.id,
667 + intent: { intentDigest: '2'.repeat(64) },
668 + expectedReview: reviewOf(workspace)
669 + });
670 + assert.equal(sealed.state, 'READY');
671 + assert.equal(repeated.id, sealed.id);
672 +});
673 +
674 +test('a message-bound review seals only proposed material matching the current workspace', async () => {
675 + const { client, states } = fixture();
676 + const workspace = await client.createWorkspace(initial);
677 + await client.setCommitMessage({
678 + ownerId: 'A',
679 + workspaceId: workspace.id,
680 + message: 'Reviewed message',
681 + digest: '1'.repeat(64)
682 + });
683 + const before = structuredClone(states.get('A').data);
684 + for (const overrides of [
685 + { workspaceId: 'OTHER12345' },
686 + { repoId: 999 },
687 + { baseBranch: 'other' },
688 + { baseHeadSha: 'f'.repeat(40) },
689 + { baseTreeSha: 'f'.repeat(40) },
690 + { commitMessageDigest: 'f'.repeat(64) },
691 + { files: [] },
692 + {
693 + files: [
694 + {
695 + path: 'b.txt',
696 + sourceBlobSha: 'c'.repeat(40),
697 + contentDigest: 'd'.repeat(64)
698 + }
699 + ]
700 + },
701 + {
702 + files: [
703 + {
704 + path: 'a.txt',
705 + sourceBlobSha: 'f'.repeat(40),
706 + contentDigest: 'd'.repeat(64)
707 + }
708 + ]
709 + },
710 + {
711 + files: [
712 + {
713 + path: 'a.txt',
714 + sourceBlobSha: 'c'.repeat(40),
715 + contentDigest: 'f'.repeat(64)
716 + }
717 + ]
718 + }
719 + ]) {
720 + await assert.rejects(
721 + client.sealIntent({
722 + ownerId: 'A',
723 + workspaceId: workspace.id,
724 + intent: reviewedIntent(workspace.id, overrides),
725 + expectedReview: {
726 + ...reviewOf(workspace),
727 + commitMessageDigest: '1'.repeat(64)
728 + }
729 + }),
730 + isConflict
731 + );
732 + assert.deepEqual(states.get('A').data, before);
733 + }
734 +});
735 +
736 +test('sealing a stale review cannot replace the currently edited workspace intent', async () => {
737 + const { client, states } = fixture();
738 + const workspace = await client.createWorkspace(initial);
739 + const expectedReview = reviewOf(workspace);
740 + await client.updateWorkspaceFileDraft(edit(workspace.id));
741 + const before = structuredClone(states.get('A').data);
742 + await assert.rejects(
743 + client.sealIntent({
744 + ownerId: 'A',
745 + workspaceId: workspace.id,
746 + intent: { intentDigest: '1'.repeat(64) },
747 + expectedReview
748 + }),
749 + isConflict
750 + );
751 + assert.deepEqual(states.get('A').data, before);
752 +});
753 +
754 +test('review sealing compares the exact file set and base head rather than only matching revisions', async () => {
755 + const { client, states } = fixture();
756 + let workspace = await client.createWorkspace(initial);
757 + workspace = await client.upsertWorkspaceFile({
758 + ownerId: 'A',
759 + workspaceId: workspace.id,
760 + file: { ...initial, path: 'b.txt' }
761 + });
762 + const before = structuredClone(states.get('A').data);
763 + for (const expectedReview of [
764 + { ...reviewOf(workspace), baseHeadSha: 'f'.repeat(40) },
765 + { ...reviewOf(workspace), files: [{ path: 'a.txt', revision: 0 }] },
766 + {
767 + ...reviewOf(workspace),
768 + files: [
769 + { path: 'a.txt', revision: 0 },
770 + { path: 'c.txt', revision: 0 }
771 + ]
772 + }
773 + ]) {
774 + await assert.rejects(
775 + client.sealIntent({
776 + ownerId: 'A',
777 + workspaceId: workspace.id,
778 + intent: { intentDigest: '1'.repeat(64) },
779 + expectedReview
780 + }),
781 + isConflict
782 + );
783 + assert.deepEqual(states.get('A').data, before);
784 + }
785 +});
786 +
787 +test('an edit queued before review sealing wins and rejects the stale review atomically', async () => {
788 + const { client } = fixture();
789 + const workspace = await client.createWorkspace(initial);
790 + const [saved, sealed] = await Promise.allSettled([
791 + client.updateWorkspaceFileDraft(edit(workspace.id)),
792 + client.sealIntent({
793 + ownerId: 'A',
794 + workspaceId: workspace.id,
795 + intent: { intentDigest: '1'.repeat(64) },
796 + expectedReview: reviewOf(workspace)
797 + })
798 + ]);
799 + assert.equal(saved.status, 'fulfilled');
800 + assert.equal(sealed.status, 'rejected');
801 + isConflict(sealed.reason);
802 + const stored = await client.getWorkspace({
803 + ownerId: 'A',
804 + workspaceId: workspace.id
805 + });
806 + assert.equal(stored.files[0].revision, 1);
807 + assert.equal(stored.currentIntentId, null);
808 + assert.equal(stored.state, 'DRAFT');
809 +});
810 +
811 +test('an edit queued after a matching review seal invalidates its READY intent', async () => {
812 + const { client } = fixture();
813 + const workspace = await client.createWorkspace(initial);
814 + const [sealed] = await Promise.all([
815 + client.sealIntent({
816 + ownerId: 'A',
817 + workspaceId: workspace.id,
818 + intent: { intentDigest: '1'.repeat(64) },
819 + expectedReview: reviewOf(workspace)
820 + }),
821 + client.updateWorkspaceFileDraft(edit(workspace.id))
822 + ]);
823 + assert.equal(sealed.state, 'READY');
824 + const stored = await client.getWorkspace({
825 + ownerId: 'A',
826 + workspaceId: workspace.id
827 + });
828 + assert.equal(stored.files[0].revision, 1);
829 + assert.equal(stored.currentIntentId, null);
830 + assert.equal(stored.state, 'DRAFT');
831 +});
test/studio-worker.test.js new
+66
@@ -0,0 +1,66 @@
1 +import test from 'node:test';
2 +import assert from 'node:assert/strict';
3 +import worker from '../src/index.js';
4 +import { KillSwitchGuidedNexaDevBot } from '../src/kill-switch-bot.js';
5 +import { makeReplayNamespace } from './helpers/replay-namespace.js';
6 +
7 +test('Worker serves Mini App entry assets and rejects unauthenticated Studio API access', async () => {
8 + const response = await worker.fetch(
9 + new Request('https://acceptance.test/studio/'),
10 + {
11 + ASSETS: {
12 + fetch: async () =>
13 + new Response(
14 + '<html><meta name="csp-nonce" content="__NEXA_NONCE__"></html>',
15 + { headers: { 'content-type': 'text/html' } }
16 + )
17 + }
18 + }
19 + );
20 + assert.equal(response.status, 200);
21 + assert.doesNotMatch(
22 + response.headers.get('content-security-policy'),
23 + /unsafe-inline/
24 + );
25 + const api = await worker.fetch(
26 + new Request('https://acceptance.test/api/v1/studio'),
27 + { TELEGRAM_BOT_TOKEN: '12345:test', OWNER_TELEGRAM_ID: '42' }
28 + );
29 + assert.equal(api.status, 403);
30 + assert.equal(api.headers.get('cache-control'), 'no-store');
31 +});
32 +
33 +test('webhook derives primary Mini App entry from its own origin and keeps explicit configuration', async () => {
34 + const original = KillSwitchGuidedNexaDevBot.prototype.handleUpdate;
35 + KillSwitchGuidedNexaDevBot.prototype.handleUpdate = async function () {
36 + return { ok: true, studioUrl: this.env.STUDIO_URL };
37 + };
38 + try {
39 + for (const configured of [undefined, 'https://custom.test/studio/', '']) {
40 + const response = await worker.fetch(
41 + new Request('https://acceptance.test/telegram/webhook', {
42 + method: 'POST',
43 + headers: { 'X-Telegram-Bot-Api-Secret-Token': 'webhook' },
44 + body: JSON.stringify({
45 + update_id: 1,
46 + message: { from: { id: 42 }, chat: { id: 42 }, text: '/start' }
47 + })
48 + }),
49 + {
50 + OWNER_TELEGRAM_ID: '42',
51 + TELEGRAM_BOT_TOKEN: '12345:test',
52 + TELEGRAM_WEBHOOK_SECRET: 'webhook',
53 + APPROVAL_REPLAY_GUARD: makeReplayNamespace(),
54 + ...(configured === undefined ? {} : { STUDIO_URL: configured })
55 + }
56 + );
57 + assert.equal(response.status, 200);
58 + assert.equal(
59 + (await response.json()).studioUrl,
60 + configured ?? 'https://acceptance.test/studio/'
61 + );
62 + }
63 + } finally {
64 + KillSwitchGuidedNexaDevBot.prototype.handleUpdate = original;
65 + }
66 +});
test/telegram-persistent-menu-input.test.js
+19 -11
@@ -1,32 +1,40 @@
1 import test from 'node:test';
2 import assert from 'node:assert/strict';
3 import { NexaDevBot } from '../src/bot.js';
4 +import { GuidedNexaDevBot } from '../src/guide-bot.js';
5
6 const WORKSPACE_ID = 'W000000001';
7
7 -test('/start installs a persistent bottom quick menu and still sends the inline main menu', async () => {
8 - const bot = new NexaDevBot({});
8 +test('/start replaces the legacy persistent keyboard with the Studio launch button', async () => {
9 + const bot = new GuidedNexaDevBot({ OWNER_TELEGRAM_ID: '7' });
10 const sent = [];
11 bot.telegram.sendMessage = async (chatId, text, replyMarkup) => {
12 sent.push({ chatId, text, replyMarkup });
13 return { ok: true, result: { message_id: 100 + sent.length } };
14 };
15 + bot.telegram.setChatMenuButton = async () => ({ ok: true });
16
17 const result = await bot.handleMessage({
16 - chat: { id: 7 },
17 - from: { id: 42 },
18 + chat: { id: 7, type: 'private' },
19 + from: { id: 7 },
20 text: '/start'
21 });
22
23 assert.equal(result.ok, true);
24 assert.equal(sent.length, 2);
23 - assert.equal(sent[0].replyMarkup.is_persistent, true);
24 - assert.equal(sent[0].replyMarkup.resize_keyboard, true);
25 - assert.deepEqual(
26 - sent[0].replyMarkup.keyboard.flat().map((button) => button.text),
27 - ['🏠 منوی اصلی', '📁 پروژه‌ها', '📊 وضعیت', '🔧 ابزارها', '🔐 امنیت']
28 - );
29 - assert.ok(sent[1].replyMarkup.inline_keyboard);
25 + assert.deepEqual(sent[0].replyMarkup, { remove_keyboard: true });
26 + assert.deepEqual(sent[1].replyMarkup, {
27 + inline_keyboard: [
28 + [
29 + {
30 + text: 'باز کردن Nexa Studio',
31 + web_app: {
32 + url: 'https://nexa-dev-bot.davoodmehraban89.workers.dev/studio/'
33 + }
34 + }
35 + ]
36 + ]
37 + });
38 });
39
40 test('persistent menu text has precedence over pending draft input', async () => {
web/index.html new
+22
@@ -0,0 +1,22 @@
1 +<!doctype html>
2 +<html lang="fa" dir="rtl">
3 + <head>
4 + <meta charset="UTF-8" />
5 + <meta
6 + name="viewport"
7 + content="width=device-width, initial-scale=1, viewport-fit=cover"
8 + />
9 + <meta name="theme-color" content="#101820" />
10 + <meta name="csp-nonce" content="__NEXA_NONCE__" />
11 + <meta
12 + name="description"
13 + content="فضای کار امن برای ویرایش مخازن GitHub در تلگرام"
14 + />
15 + <title>Nexa Studio</title>
16 + <script src="https://telegram.org/js/telegram-web-app.js"></script>
17 + </head>
18 + <body>
19 + <div id="root"></div>
20 + <script type="module" src="/src/main.tsx"></script>
21 + </body>
22 +</html>
web/src/App.tsx new
+1415
@@ -0,0 +1,1415 @@
1 +import { useEffect, useMemo, useState } from 'react';
2 +import { ApiError, createApi } from './api.js';
3 +import { CodeEditor, searchEditor } from './CodeEditor.js';
4 +import type {
5 + Approval,
6 + Diff,
7 + Limits,
8 + Repository,
9 + ReviewSnapshot,
10 + TreeItem,
11 + Workspace,
12 + WorkspaceResponse
13 +} from './types.js';
14 +
15 +type Page = 'home' | 'tree' | 'editor' | 'review' | 'approval';
16 +type Failure = { message: string; retry?: () => void };
17 +const encoder = new TextEncoder();
18 +const number = (value: number) => value.toLocaleString('fa-IR');
19 +const bytes = (value: string) => encoder.encode(value).length;
20 +const chars = (value: string) => Array.from(value).length;
21 +const fileName = (path: string) => path.split('/').pop() || path;
22 +const workspaceStorageKey = 'nexa.studio.workspace';
23 +const workspaceIdPattern = /^[A-Za-z0-9]{10}$/;
24 +function rememberWorkspace(id: string | null) {
25 + try {
26 + if (id && workspaceIdPattern.test(id))
27 + window.localStorage.setItem(workspaceStorageKey, id);
28 + else window.localStorage.removeItem(workspaceStorageKey);
29 + } catch {
30 + // Storage is optional; signed launch data and draft contents stay in memory.
31 + }
32 +}
33 +function rememberedWorkspace() {
34 + try {
35 + const id = window.localStorage.getItem(workspaceStorageKey);
36 + if (!id || workspaceIdPattern.test(id)) return id;
37 + rememberWorkspace(null);
38 + } catch {
39 + // Telegram browsers may disable local storage.
40 + }
41 + return null;
42 +}
43 +const unavailableWorkspace = (error: unknown) =>
44 + error instanceof ApiError && [400, 401, 403, 404, 410].includes(error.status);
45 +
46 +function Icon({
47 + name,
48 + className = ''
49 +}: {
50 + name:
51 + | 'code'
52 + | 'repo'
53 + | 'folder'
54 + | 'file'
55 + | 'arrow'
56 + | 'check'
57 + | 'lock'
58 + | 'search'
59 + | 'plus';
60 + className?: string;
61 +}) {
62 + const paths = {
63 + code: (
64 + <>
65 + <path d="m8 7-5 5 5 5M16 7l5 5-5 5M14 4l-4 16" />
66 + </>
67 + ),
68 + repo: (
69 + <>
70 + <path d="M4 4a2 2 0 0 1 2-2h14v20H6a2 2 0 0 1-2-2Zm0 13h16M8 6h7" />
71 + </>
72 + ),
73 + folder: <path d="M3 7V4h7l2 3h9v13H3Z" />,
74 + file: (
75 + <>
76 + <path d="M5 2h9l5 5v15H5ZM14 2v6h5M8 12h8M8 16h6" />
77 + </>
78 + ),
79 + arrow: <path d="m9 5 7 7-7 7M16 12H3" />,
80 + check: <path d="m5 12 4 4L19 6" />,
81 + lock: (
82 + <>
83 + <rect x="5" y="10" width="14" height="11" rx="2" />
84 + <path d="M8 10V7a4 4 0 0 1 8 0v3M12 14v3" />
85 + </>
86 + ),
87 + search: (
88 + <>
89 + <circle cx="10" cy="10" r="6" />
90 + <path d="m15 15 6 6" />
91 + </>
92 + ),
93 + plus: <path d="M12 4v16M4 12h16" />
94 + };
95 + return (
96 + <svg
97 + className={className}
98 + width="20"
99 + height="20"
100 + viewBox="0 0 24 24"
101 + fill="none"
102 + stroke="currentColor"
103 + strokeWidth="1.7"
104 + strokeLinecap="round"
105 + strokeLinejoin="round"
106 + aria-hidden="true"
107 + >
108 + {paths[name]}
109 + </svg>
110 + );
111 +}
112 +
113 +export function App({ fetcher = fetch }: { fetcher?: typeof fetch }) {
114 + const [telegram] = useState(() => window.Telegram?.WebApp);
115 + const [initData] = useState(() => telegram?.initData || '');
116 + const api = useMemo(() => createApi(initData, fetcher), [initData, fetcher]);
117 + const [page, setPage] = useState<Page>('home');
118 + const [userName, setUserName] = useState('');
119 + const [repositories, setRepositories] = useState<Repository[]>([]);
120 + const [limits, setLimits] = useState<Limits | null>(null);
121 + const [repository, setRepository] = useState<Repository | null>(null);
122 + const [treePath, setTreePath] = useState('');
123 + const [items, setItems] = useState<TreeItem[]>([]);
124 + const [addingFile, setAddingFile] = useState(false);
125 + const [workspace, setWorkspace] = useState<Workspace | null>(null);
126 + const [resumableWorkspace, setResumableWorkspace] =
127 + useState<Workspace | null>(null);
128 + const [drafts, setDrafts] = useState<Record<string, string>>({});
129 + const [activePath, setActivePath] = useState('');
130 + const [message, setMessage] = useState('');
131 + const [diff, setDiff] = useState<Diff | null>(null);
132 + const [reviewSnapshot, setReviewSnapshot] = useState<ReviewSnapshot | null>(
133 + null
134 + );
135 + const [approval, setApproval] = useState<Approval | null>(null);
136 + const [fontSize, setFontSize] = useState(14);
137 + const [busy, setBusy] = useState('');
138 + const [failure, setFailure] = useState<Failure | null>(null);
139 + const [status, setStatus] = useState('');
140 + const [conflict, setConflict] = useState<{
141 + latest: WorkspaceResponse;
142 + path: string;
143 + } | null>(null);
144 + const [discardAction, setDiscardAction] = useState<(() => void) | null>(null);
145 + const activeFile = workspace?.files.find((file) => file.path === activePath);
146 + const text = drafts[activePath] ?? '';
147 + const dirtyPaths =
148 + workspace?.files
149 + .filter(
150 + (file) => (drafts[file.path] ?? file.draftText) !== file.draftText
151 + )
152 + .map((file) => file.path) || [];
153 + const hasUnsaved = dirtyPaths.length > 0;
154 + const aggregateBytes =
155 + workspace?.files.reduce(
156 + (total, file) => total + bytes(drafts[file.path] ?? file.draftText),
157 + 0
158 + ) || 0;
159 + const overLimit =
160 + !!limits &&
161 + (bytes(text) > limits.maxBytes ||
162 + chars(text) > limits.maxChars ||
163 + aggregateBytes > limits.maxAggregateBytes);
164 + const editable = workspace?.state === 'DRAFT' && !busy && !conflict;
165 +
166 + function showError(error: unknown, retry?: () => void) {
167 + setFailure({
168 + message:
169 + error instanceof ApiError
170 + ? error.message
171 + : 'ارتباط با سرویس برقرار نشد. اتصال را بررسی و دوباره تلاش کن.',
172 + retry
173 + });
174 + }
175 + async function perform(
176 + label: string,
177 + action: () => Promise<void>,
178 + retry?: () => void
179 + ) {
180 + setBusy(label);
181 + setFailure(null);
182 + try {
183 + await action();
184 + } catch (error) {
185 + showError(error, retry);
186 + } finally {
187 + setBusy('');
188 + }
189 + }
190 + function acceptWorkspace(
191 + response: WorkspaceResponse,
192 + preserve = false,
193 + acceptedPath?: string
194 + ) {
195 + setReviewSnapshot(null);
196 + rememberWorkspace(response.workspace.id);
197 + setResumableWorkspace(response.workspace);
198 + setWorkspace((current) => ({
199 + ...response.workspace,
200 + files: response.workspace.files.map((file) => {
201 + const previous = current?.files.find(
202 + (entry) => entry.path === file.path
203 + );
204 + // An unrelated response must never authorize overwriting an unseen edit.
205 + return preserve && previous && file.path !== acceptedPath
206 + ? previous
207 + : file;
208 + })
209 + }));
210 + if (response.limits) setLimits(response.limits);
211 + setDrafts((current) =>
212 + Object.fromEntries(
213 + response.workspace.files.map((file) => [
214 + file.path,
215 + preserve && current[file.path] !== undefined
216 + ? current[file.path]
217 + : file.draftText
218 + ])
219 + )
220 + );
221 + }
222 + async function getRememberedWorkspace(id: string) {
223 + try {
224 + const result = await api<WorkspaceResponse>(`/workspaces/${id}`);
225 + if (
226 + result.workspace.id !== id ||
227 + !['DRAFT', 'READY', 'COMMITTED', 'COMMITTING'].includes(
228 + result.workspace.state
229 + )
230 + ) {
231 + rememberWorkspace(null);
232 + setResumableWorkspace(null);
233 + return null;
234 + }
235 + setResumableWorkspace(result.workspace);
236 + return result;
237 + } catch (error) {
238 + if (!unavailableWorkspace(error)) throw error;
239 + rememberWorkspace(null);
240 + setResumableWorkspace(null);
241 + return null;
242 + }
243 + }
244 + async function loadHome() {
245 + await perform(
246 + 'در حال دریافت مخازن…',
247 + async () => {
248 + let session;
249 + try {
250 + session = await api<{ user: { name: string }; limits: Limits }>('');
251 + } catch (error) {
252 + if (unavailableWorkspace(error)) {
253 + rememberWorkspace(null);
254 + setResumableWorkspace(null);
255 + }
256 + throw error;
257 + }
258 + setUserName(session.user.name);
259 + setLimits(session.limits);
260 + const savedId = rememberedWorkspace();
261 + const [repos] = await Promise.all([
262 + api<{ repositories: Repository[] }>('/repos'),
263 + savedId ? getRememberedWorkspace(savedId) : Promise.resolve(null)
264 + ]);
265 + setRepositories(repos.repositories);
266 + setPage('home');
267 + },
268 + () => void loadHome()
269 + );
270 + }
271 + async function continueWorkspace() {
272 + if (!resumableWorkspace) return;
273 + await perform(
274 + 'در حال دریافت فضای کاری…',
275 + async () => {
276 + const result = await getRememberedWorkspace(resumableWorkspace.id);
277 + if (!result) return;
278 + const restored = result.workspace;
279 + acceptWorkspace(result);
280 + setRepository(
281 + repositories.find(
282 + (repo) => String(repo.id) === String(restored.repoId)
283 + ) || null
284 + );
285 + setActivePath(restored.path || restored.files[0]?.path || '');
286 + setMessage(restored.commitMessage || '');
287 + setApproval(null);
288 + setDiff(null);
289 + setConflict(null);
290 + setStatus('');
291 + if (restored.state === 'READY') {
292 + const reviewed = await api<{ diff: Diff; review: ReviewSnapshot }>(
293 + `/workspaces/${restored.id}/diff`
294 + );
295 + if (!reviewed.review) throw new Error('Review snapshot unavailable');
296 + setDiff(reviewed.diff);
297 + setReviewSnapshot(reviewed.review);
298 + setPage('review');
299 + } else if (
300 + restored.state === 'COMMITTED' ||
301 + restored.state === 'COMMITTING'
302 + ) {
303 + setPage('approval');
304 + } else setPage('editor');
305 + },
306 + () => void continueWorkspace()
307 + );
308 + }
309 + useEffect(() => {
310 + if (!initData) return;
311 + telegram?.ready?.();
312 + telegram?.expand?.();
313 + void loadHome();
314 + // The signed Telegram launch data stays in memory for this mount only.
315 + }, [api]);
316 + useEffect(() => {
317 + const beforeUnload = (event: BeforeUnloadEvent) => {
318 + if (hasUnsaved) {
319 + event.preventDefault();
320 + event.returnValue = '';
321 + }
322 + };
323 + window.addEventListener('beforeunload', beforeUnload);
324 + if (hasUnsaved) telegram?.enableClosingConfirmation?.();
325 + else telegram?.disableClosingConfirmation?.();
326 + return () => window.removeEventListener('beforeunload', beforeUnload);
327 + }, [hasUnsaved, telegram]);
328 + function guard(action: () => void) {
329 + if (hasUnsaved) setDiscardAction(() => action);
330 + else action();
331 + }
332 + function backToFiles() {
333 + guard(() => {
334 + if (!repository) {
335 + setPage('home');
336 + return;
337 + }
338 + setDrafts(
339 + Object.fromEntries(
340 + workspace?.files.map((file) => [file.path, file.draftText]) || []
341 + )
342 + );
343 + setAddingFile(false);
344 + setConflict(null);
345 + setStatus('');
346 + void loadTree(repository, '');
347 + });
348 + }
349 + useEffect(() => {
350 + const button = telegram?.BackButton;
351 + if (!button) return;
352 + const back = () => {
353 + if (busy) return;
354 + if (page === 'review' || (page === 'tree' && addingFile))
355 + setPage('editor');
356 + else if (page === 'editor') backToFiles();
357 + else if (page === 'tree') setPage('home');
358 + else if (page === 'approval') guard(() => telegram?.close?.());
359 + };
360 + if (page === 'home') button.hide();
361 + else button.show();
362 + button.onClick(back);
363 + return () => button.offClick(back);
364 + }, [page, busy, hasUnsaved, addingFile, repository]);
365 +
366 + async function loadTree(repo: Repository, path: string, adding = false) {
367 + await perform(
368 + 'در حال دریافت فایل‌ها…',
369 + async () => {
370 + const query = new URLSearchParams({ repoId: String(repo.id), path });
371 + if (adding && workspace) query.set('workspaceId', workspace.id);
372 + const result = await api<{ items: TreeItem[]; path: string }>(
373 + `/tree?${query}`
374 + );
375 + setRepository(repo);
376 + setTreePath(result.path);
377 + setItems(result.items);
378 + setAddingFile(adding);
379 + setPage('tree');
380 + },
381 + () => void loadTree(repo, path, adding)
382 + );
383 + }
384 + async function openFile(item: TreeItem) {
385 + if (item.type === 'dir' || item.type === 'directory') {
386 + if (repository) await loadTree(repository, item.path, addingFile);
387 + return;
388 + }
389 + await perform(
390 + 'در حال باز کردن فایل…',
391 + async () => {
392 + if (addingFile && workspace) {
393 + const result = await api<WorkspaceResponse>(
394 + `/workspaces/${workspace.id}/files`,
395 + { method: 'POST', body: JSON.stringify({ refId: item.refId }) }
396 + );
397 + acceptWorkspace(result, true);
398 + setActivePath(item.path);
399 + } else {
400 + const result = await api<WorkspaceResponse>('/workspaces', {
401 + method: 'POST',
402 + body: JSON.stringify({ refId: item.refId })
403 + });
404 + acceptWorkspace(result);
405 + setActivePath(
406 + result.workspace.path || result.workspace.files[0].path
407 + );
408 + setMessage(result.workspace.commitMessage || '');
409 + setApproval(null);
410 + setDiff(null);
411 + }
412 + setAddingFile(false);
413 + setStatus('');
414 + setPage('editor');
415 + },
416 + () => void openFile(item)
417 + );
418 + }
419 + async function saveFile() {
420 + if (
421 + !workspace ||
422 + !activeFile ||
423 + overLimit ||
424 + !editable ||
425 + !dirtyPaths.includes(activePath)
426 + )
427 + return;
428 + const selectedPath = activePath;
429 + const savedText = text;
430 + await perform(
431 + 'در حال ذخیره…',
432 + async () => {
433 + try {
434 + const result = await api<WorkspaceResponse>(
435 + `/workspaces/${workspace.id}/files`,
436 + {
437 + method: 'PUT',
438 + headers: { 'if-match': String(activeFile.revision) },
439 + body: JSON.stringify({ path: selectedPath, text: savedText })
440 + }
441 + );
442 + acceptWorkspace(result, true, selectedPath);
443 + setDrafts((current) => ({
444 + ...current,
445 + [selectedPath]:
446 + result.workspace.files.find((file) => file.path === selectedPath)
447 + ?.draftText ?? savedText
448 + }));
449 + setStatus(
450 + 'تغییرات در فضای کاری ذخیره شد. هنوز چیزی در GitHub ثبت نشده است.'
451 + );
452 + } catch (error) {
453 + if (!(error instanceof ApiError) || error.status !== 409) throw error;
454 + const latest = await api<WorkspaceResponse>(
455 + `/workspaces/${workspace.id}`
456 + );
457 + setConflict({ latest, path: selectedPath });
458 + setStatus('');
459 + }
460 + },
461 + () => void saveFile()
462 + );
463 + }
464 + function resolveConflict(keepMine: boolean) {
465 + if (!conflict) return;
466 + acceptWorkspace(conflict.latest, true, conflict.path);
467 + if (!keepMine) {
468 + const latest = conflict.latest.workspace.files.find(
469 + (file) => file.path === conflict.path
470 + );
471 + if (latest)
472 + setDrafts((current) => ({
473 + ...current,
474 + [conflict.path]: latest.draftText
475 + }));
476 + }
477 + setConflict(null);
478 + setStatus(
479 + keepMine
480 + ? 'نسخه تو نگه داشته شد. برای جایگزینی نسخه سرور، دوباره «ذخیره تغییرات» را بزن.'
481 + : 'نسخه جدید بارگیری شد. می‌توانی ویرایش را ادامه بدهی.'
482 + );
483 + }
484 + async function review(refresh = false) {
485 + if (!workspace || hasUnsaved || conflict) return;
486 + setReviewSnapshot(null);
487 + await perform(
488 + 'در حال آماده‌سازی Diff…',
489 + async () => {
490 + if (refresh) {
491 + const latest = await api<WorkspaceResponse>(
492 + `/workspaces/${workspace.id}`
493 + );
494 + acceptWorkspace(latest);
495 + }
496 + const result = await api<{ diff: Diff; review: ReviewSnapshot }>(
497 + `/workspaces/${workspace.id}/diff`
498 + );
499 + if (!result.review) throw new Error('Review snapshot unavailable');
500 + setDiff(result.diff);
501 + setReviewSnapshot(result.review);
502 + setPage('review');
503 + setStatus('');
504 + },
505 + () => void review(refresh)
506 + );
507 + }
508 + async function requestApproval() {
509 + if (
510 + !workspace ||
511 + !reviewSnapshot ||
512 + !message.trim() ||
513 + chars(message.trim()) > 120 ||
514 + hasUnsaved ||
515 + diff?.truncated
516 + )
517 + return;
518 + const reviewed = reviewSnapshot;
519 + const expectedMessage = message.trim();
520 + await perform(
521 + 'در حال ارسال درخواست تأیید…',
522 + async () => {
523 + try {
524 + await api<WorkspaceResponse>(`/workspaces/${workspace.id}/message`, {
525 + method: 'PUT',
526 + body: JSON.stringify({ message: expectedMessage })
527 + });
528 + // A message response may contain a concurrent edit. Keep the displayed review fixed.
529 + setWorkspace((current) =>
530 + current ? { ...current, commitMessage: expectedMessage } : current
531 + );
532 + const requested = await api<Approval>(
533 + `/workspaces/${workspace.id}/approval`,
534 + {
535 + method: 'POST',
536 + body: JSON.stringify({
537 + review: reviewed,
538 + message: expectedMessage
539 + })
540 + }
541 + );
542 + if (!requested.approvalRequested)
543 + throw new Error('Approval was not requested');
544 + setApproval(requested);
545 + setPage('approval');
546 + } catch (error) {
547 + if (!(error instanceof ApiError) || error.status !== 409) throw error;
548 + setReviewSnapshot(null);
549 + showError(error);
550 + }
551 + },
552 + () => void requestApproval()
553 + );
554 + }
555 + async function refreshWorkspace() {
556 + if (!workspace) return;
557 + await perform(
558 + 'در حال بررسی نتیجه…',
559 + async () => {
560 + const result = await api<WorkspaceResponse>(
561 + `/workspaces/${workspace.id}`
562 + );
563 + acceptWorkspace(result);
564 + setStatus(
565 + result.workspace.state === 'COMMITTED'
566 + ? ''
567 + : 'هنوز نتیجه ثبت Commit دریافت نشده است. وضعیت تأیید را در تلگرام بررسی کن.'
568 + );
569 + },
570 + () => void refreshWorkspace()
571 + );
572 + }
573 + async function cancelWorkspace() {
574 + if (!workspace) return;
575 + await perform(
576 + 'در حال لغو فضای کاری…',
577 + async () => {
578 + await api(`/workspaces/${workspace.id}`, { method: 'DELETE' });
579 + rememberWorkspace(null);
580 + setResumableWorkspace(null);
581 + setWorkspace(null);
582 + setDrafts({});
583 + setApproval(null);
584 + setStatus('فضای کاری لغو شد.');
585 + setPage('home');
586 + },
587 + () => void cancelWorkspace()
588 + );
589 + }
590 +
591 + useEffect(() => {
592 + if (!discardAction) return;
593 + const previousFocus =
594 + document.activeElement instanceof HTMLElement
595 + ? document.activeElement
596 + : null;
597 + const dialog = document.querySelector<HTMLElement>('[role="dialog"]');
598 + const focusable = () =>
599 + Array.from(
600 + dialog?.querySelectorAll<HTMLElement>(
601 + 'button:not(:disabled), a[href], input:not(:disabled), select:not(:disabled), [tabindex="0"]'
602 + ) || []
603 + );
604 + focusable()[0]?.focus();
605 + const keydown = (event: KeyboardEvent) => {
606 + if (event.key === 'Escape') {
607 + event.preventDefault();
608 + setDiscardAction(null);
609 + }
610 + if (event.key === 'Tab') {
611 + const controls = focusable();
612 + const first = controls[0];
613 + const last = controls[controls.length - 1];
614 + if (event.shiftKey && document.activeElement === first) {
615 + event.preventDefault();
616 + last?.focus();
617 + } else if (!event.shiftKey && document.activeElement === last) {
618 + event.preventDefault();
619 + first?.focus();
620 + }
621 + }
622 + };
623 + document.addEventListener('keydown', keydown);
624 + return () => {
625 + document.removeEventListener('keydown', keydown);
626 + if (previousFocus?.isConnected) previousFocus.focus();
627 + };
628 + }, [discardAction]);
629 +
630 + const repoLabel = (
631 + <span dir="ltr">{repository?.fullName || workspace?.repoFullName}</span>
632 + );
633 + const workspaceHeader = workspace && (
634 + <div className="workspace-header">
635 + <div>
636 + <p className="eyebrow">فضای کاری</p>
637 + <h1 className="workspace-title" dir="ltr">
638 + {workspace.repoFullName}
639 + </h1>
640 + <div className="workspace-meta">
641 + <span>
642 + مبنای تغییر <bdi>{workspace.baseBranch}</bdi>
643 + </span>
644 + <span className="inline-code" dir="ltr">
645 + {workspace.baseHeadSha.slice(0, 10)}
646 + </span>
647 + <span>{number(workspace.files.length)} فایل</span>
648 + </div>
649 + </div>
650 + <span className="badge">
651 + {workspace.state === 'COMMITTED' ? 'ثبت‌شده' : 'پیش‌نویس امن'}
652 + </span>
653 + </div>
654 + );
655 +
656 + return (
657 + <div className="app-shell" dir="rtl">
658 + <header className="topbar">
659 + <div className="brand">
660 + <span className="brand-mark">
661 + <Icon name="code" />
662 + </span>
663 + <span>
664 + <span className="brand-name">
665 + Nexa <strong>Studio</strong>
666 + </span>
667 + <span className="brand-subtitle">
668 + از ایده تا تغییر، داخل تلگرام
669 + </span>
670 + </span>
671 + </div>
672 + {userName && <span className="user-pill">{userName}</span>}
673 + </header>
674 + <main className="app-main" aria-busy={!!busy}>
675 + {!initData ? (
676 + <section className="empty-state">
677 + <span className="brand-mark">
678 + <Icon name="lock" />
679 + </span>
680 + <h1>استودیوی تو، داخل تلگرام</h1>
681 + <p>
682 + برای دسترسی امن به مخازن، Nexa Studio را از دکمه داخل ربات تلگرام
683 + باز کن.
684 + </p>
685 + <button
686 + className="button secondary"
687 + type="button"
688 + onClick={() => window.location.reload()}
689 + >
690 + بررسی دوباره
691 + </button>
692 + </section>
693 + ) : (
694 + <>
695 + {failure && (
696 + <div className="notice error" role="alert">
697 + <div>
698 + <strong className="notice-title">درخواست انجام نشد</strong>
699 + <p>{failure.message}</p>
700 + </div>
701 + {failure.retry && (
702 + <button
703 + className="button secondary"
704 + type="button"
705 + disabled={!!busy}
706 + onClick={failure.retry}
707 + >
708 + تلاش دوباره
709 + </button>
710 + )}
711 + </div>
712 + )}
713 + {status && (
714 + <div className="notice info" role="status">
715 + <Icon name="check" />
716 + <p>{status}</p>
717 + </div>
718 + )}
719 + {busy && (
720 + <div className="loading-state" role="status">
721 + <span className="spinner" />
722 + {busy}
723 + </div>
724 + )}
725 + {page === 'home' && (
726 + <section>
727 + <div className="screen-heading">
728 + <p className="eyebrow">میز کار تو</p>
729 + <h1 className="screen-title">
730 + {userName
731 + ? `${userName}، از کجا شروع کنیم؟`
732 + : 'یک تغییر کوچک، یک قدم جلوتر.'}
733 + </h1>
734 + <p className="screen-description">
735 + مخزنت را باز کن، فایل‌ها را ویرایش کن و تغییرات را پیش از
736 + تأیید ببین.
737 + </p>
738 + </div>
739 + {resumableWorkspace && (
740 + <div className="notice info">
741 + <div>
742 + <strong>فضای کاری قبلی</strong>
743 + <p dir="ltr">{resumableWorkspace.repoFullName}</p>
744 + </div>
745 + <button
746 + className="button secondary"
747 + type="button"
748 + disabled={!!busy}
749 + onClick={() => guard(() => void continueWorkspace())}
750 + >
751 + ادامه فضای کاری
752 + </button>
753 + </div>
754 + )}
755 + <div className="panel-heading">
756 + <h2>مخازن GitHub</h2>
757 + <button
758 + className="button quiet small"
759 + type="button"
760 + disabled={!!busy}
761 + onClick={() => void loadHome()}
762 + >
763 + تازه‌سازی
764 + </button>
765 + </div>
766 + {!busy && !failure && repositories.length === 0 ? (
767 + <div className="empty-state">
768 + <Icon name="repo" />
769 + <h2>مخزنی برای نمایش نیست</h2>
770 + <p>
771 + دسترسی حساب متصل به مخازن را در GitHub بررسی کن، سپس
772 + دوباره دریافت کن.
773 + </p>
774 + <button
775 + className="button secondary"
776 + type="button"
777 + onClick={() => void loadHome()}
778 + >
779 + دریافت دوباره مخازن
780 + </button>
781 + </div>
782 + ) : (
783 + <div className="repo-list">
784 + {repositories.map((repo) => (
785 + <button
786 + key={repo.id}
787 + className="repo-card"
788 + type="button"
789 + disabled={!!busy}
790 + onClick={() => void loadTree(repo, '')}
791 + >
792 + <span className="repo-icon">
793 + <Icon name="repo" />
794 + </span>
795 + <span className="repo-copy">
796 + <span className="repo-name" dir="ltr">
797 + {repo.name}
798 + </span>
799 + <span className="repo-description">
800 + {repo.description || repo.fullName}
801 + </span>
802 + <span className="repo-meta">
803 + <span>{repo.private ? 'خصوصی' : 'عمومی'}</span>
804 + <bdi>{repo.defaultBranch}</bdi>
805 + </span>
806 + </span>
807 + <Icon name="arrow" />
808 + </button>
809 + ))}
810 + </div>
811 + )}
812 + <p className="screen-footer">
813 + <Icon name="lock" />
814 + هیچ تغییری بدون تأیید امن تو در تلگرام ثبت نمی‌شود.
815 + </p>
816 + </section>
817 + )}
818 + {page === 'tree' && repository && (
819 + <section>
820 + <button
821 + className="button quiet back-button"
822 + type="button"
823 + disabled={!!busy}
824 + onClick={() => {
825 + if (addingFile) setPage('editor');
826 + else setPage('home');
827 + }}
828 + >
829 + <Icon name="arrow" />
830 + {addingFile ? 'بازگشت به ویرایشگر' : 'همه مخازن'}
831 + </button>
832 + <div className="screen-heading">
833 + <p className="eyebrow">
834 + {addingFile ? 'افزودن به فضای کاری' : 'مرور مخزن'}
835 + </p>
836 + <h1 className="screen-title" dir="ltr">
837 + {repository.name}
838 + </h1>
839 + <p className="screen-description">
840 + {addingFile
841 + ? 'فایل بعدی را برای ویرایش کنار فایل‌های فعلی انتخاب کن.'
842 + : 'یک فایل متنی را انتخاب کن تا فضای کاری‌ات باز شود.'}
843 + </p>
844 + </div>
845 + <div className="browser-panel">
846 + <nav className="breadcrumb" aria-label="مسیر مخزن">
847 + <button
848 + className="button quiet small"
849 + type="button"
850 + disabled={!!busy}
851 + onClick={() => void loadTree(repository, '', addingFile)}
852 + >
853 + {repoLabel}
854 + </button>
855 + {treePath
856 + .split('/')
857 + .filter(Boolean)
858 + .map((part, index, parts) => (
859 + <button
860 + key={index}
861 + className="button quiet small"
862 + type="button"
863 + disabled={!!busy}
864 + onClick={() =>
865 + void loadTree(
866 + repository,
867 + parts.slice(0, index + 1).join('/'),
868 + addingFile
869 + )
870 + }
871 + >
872 + <bdi>{part}</bdi>
873 + </button>
874 + ))}
875 + </nav>
876 + {items.length ? (
877 + <div className="tree-list">
878 + {items.map((item) => {
879 + const directory =
880 + item.type === 'dir' || item.type === 'directory';
881 + const exists =
882 + addingFile &&
883 + workspace?.files.some(
884 + (file) => file.path === item.path
885 + );
886 + return (
887 + <button
888 + key={item.refId}
889 + className="tree-row"
890 + type="button"
891 + disabled={!!busy || !!exists}
892 + onClick={() => void openFile(item)}
893 + >
894 + <span className="tree-icon">
895 + <Icon name={directory ? 'folder' : 'file'} />
896 + </span>
897 + <span className="tree-name" dir="ltr">
898 + {item.name}
899 + </span>
900 + <span className="tree-detail">
901 + {exists
902 + ? 'در فضای کاری'
903 + : directory
904 + ? 'پوشه'
905 + : `${number(item.size || 0)} بایت`}
906 + </span>
907 + </button>
908 + );
909 + })}
910 + </div>
911 + ) : (
912 + <div className="empty-state">
913 + <Icon name="folder" />
914 + <h2>این پوشه خالی است</h2>
915 + <p>به ریشه مخزن برگرد و پوشه دیگری را باز کن.</p>
916 + <button
917 + className="button secondary"
918 + type="button"
919 + disabled={!!busy}
920 + onClick={() =>
921 + void loadTree(repository, '', addingFile)
922 + }
923 + >
924 + ریشه مخزن
925 + </button>
926 + </div>
927 + )}
928 + </div>
929 + {addingFile && limits && (
930 + <p className="field-help">
931 + تا {number(limits.maxFiles)} فایل و مجموع{' '}
932 + {number(limits.maxAggregateBytes)} بایت در هر فضای کاری.
933 + </p>
934 + )}
935 + </section>
936 + )}
937 + {page === 'editor' && workspace && activeFile && limits && (
938 + <section>
939 + <button
940 + className="button quiet back-button"
941 + type="button"
942 + disabled={!!busy}
943 + onClick={backToFiles}
944 + >
945 + <Icon name="arrow" />
946 + بازگشت به فایل‌ها
947 + </button>
948 + {workspaceHeader}
949 + {conflict && (
950 + <div className="conflict-panel" role="alert">
951 + <strong>نسخه این فایل تغییر کرده است</strong>
952 + <p>
953 + یک نسخه تازه روی سرور وجود دارد. نسخه تو هنوز اینجاست؛
954 + خودت انتخاب کن کدام را ادامه بدهی.
955 + </p>
956 + <div className="action-row">
957 + <button
958 + className="button primary"
959 + type="button"
960 + onClick={() => resolveConflict(true)}
961 + >
962 + نگه‌داشتن نسخه من
963 + </button>
964 + <button
965 + className="button secondary"
966 + type="button"
967 + onClick={() => resolveConflict(false)}
968 + >
969 + بارگیری نسخه جدید
970 + </button>
971 + </div>
972 + </div>
973 + )}
974 + <div className="workspace-layout">
975 + <div className="editor-panel">
976 + <div className="editor-toolbar">
977 + <div
978 + className="file-tabs"
979 + role="tablist"
980 + aria-label="فایل‌های فضای کاری"
981 + >
982 + {workspace.files.map((file) => (
983 + <button
984 + key={file.path}
985 + type="button"
986 + role="tab"
987 + title={file.path}
988 + aria-selected={file.path === activePath}
989 + disabled={!!busy || !!conflict}
990 + className={`file-tab${file.path === activePath ? ' active' : ''}${dirtyPaths.includes(file.path) ? ' dirty' : ''}`}
991 + onClick={() => {
992 + setActivePath(file.path);
993 + setStatus('');
994 + }}
995 + >
996 + <Icon name="file" />
997 + <bdi>{fileName(file.path)}</bdi>
998 + {dirtyPaths.includes(file.path) && (
999 + <span aria-label="ذخیره نشده">●</span>
1000 + )}
1001 + </button>
1002 + ))}
1003 + </div>
1004 + <div className="editor-settings">
1005 + <button
1006 + className="icon-button"
1007 + type="button"
1008 + title="جست‌وجو در فایل"
1009 + aria-label="جست‌وجو در فایل"
1010 + onClick={searchEditor}
1011 + >
1012 + <Icon name="search" />
1013 + </button>
1014 + <label className="font-control">
1015 + اندازه کد
1016 + <select
1017 + className="select-control"
1018 + aria-label="اندازه قلم کد"
1019 + value={fontSize}
1020 + onChange={(event) =>
1021 + setFontSize(Number(event.target.value))
1022 + }
1023 + >
1024 + {[12, 14, 16, 18, 20].map((size) => (
1025 + <option key={size} value={size}>
1026 + {number(size)}
1027 + </option>
1028 + ))}
1029 + </select>
1030 + </label>
1031 + </div>
1032 + </div>
1033 + <CodeEditor
1034 + value={text}
1035 + path={activePath}
1036 + readOnly={!editable}
1037 + fontSize={fontSize}
1038 + onChange={(value) => {
1039 + setReviewSnapshot(null);
1040 + setDrafts((current) => ({
1041 + ...current,
1042 + [activePath]: value
1043 + }));
1044 + setStatus('');
1045 + }}
1046 + />
1047 + <div className="editor-status">
1048 + <span>
1049 + <span
1050 + className={`status-dot ${dirtyPaths.includes(activePath) ? 'dirty' : 'saved'}`}
1051 + />
1052 + {dirtyPaths.includes(activePath)
1053 + ? 'تغییرات ذخیره نشده'
1054 + : 'ذخیره‌شده در فضای کاری'}
1055 + </span>
1056 + <span
1057 + className={`count-limit${overLimit ? ' over-limit' : ''}`}
1058 + >
1059 + {number(bytes(text))} / {number(limits.maxBytes)} بایت ·{' '}
1060 + {number(chars(text))} / {number(limits.maxChars)} نویسه
1061 + </span>
1062 + </div>
1063 + </div>
1064 + </div>
1065 + {overLimit && (
1066 + <div className="notice warning" role="alert">
1067 + سقف مجاز فایل یا مجموع فضای کاری رد شده است. پیش از ذخیره،
1068 + حجم متن را کم کن.
1069 + </div>
1070 + )}
1071 + <div className="editor-actions">
1072 + <button
1073 + className="button primary"
1074 + type="button"
1075 + disabled={
1076 + !editable || overLimit || !dirtyPaths.includes(activePath)
1077 + }
1078 + onClick={() => void saveFile()}
1079 + >
1080 + <Icon name="check" />
1081 + ذخیره تغییرات
1082 + </button>
1083 + <button
1084 + className="button secondary"
1085 + type="button"
1086 + disabled={
1087 + !!busy ||
1088 + !!conflict ||
1089 + hasUnsaved ||
1090 + !['DRAFT', 'READY'].includes(workspace.state)
1091 + }
1092 + onClick={() => void review()}
1093 + >
1094 + بازبینی تغییرات
1095 + </button>
1096 + <button
1097 + className="button quiet"
1098 + type="button"
1099 + disabled={
1100 + !!busy ||
1101 + !!conflict ||
1102 + !repository ||
1103 + workspace.files.length >= limits.maxFiles ||
1104 + workspace.state !== 'DRAFT'
1105 + }
1106 + onClick={() =>
1107 + repository && void loadTree(repository, '', true)
1108 + }
1109 + >
1110 + <Icon name="plus" />
1111 + افزودن فایل
1112 + </button>
1113 + </div>
1114 + <p className="field-help">
1115 + {hasUnsaved
1116 + ? 'هر فایل تغییرکرده را ذخیره کن تا Diff و درخواست تأیید در دسترس باشد.'
1117 + : 'ذخیره، فقط پیش‌نویس فضای کاری را به‌روز می‌کند. ثبت در GitHub به تأیید جداگانه نیاز دارد.'}
1118 + </p>
1119 + <div className="screen-footer">
1120 + <span>
1121 + مجموع فضای کاری: {number(aggregateBytes)} /{' '}
1122 + {number(limits.maxAggregateBytes)} بایت
1123 + </span>
1124 + <button
1125 + className="button quiet small danger"
1126 + type="button"
1127 + disabled={!!busy}
1128 + onClick={() =>
1129 + setDiscardAction(() => () => void cancelWorkspace())
1130 + }
1131 + >
1132 + لغو فضای کاری
1133 + </button>
1134 + </div>
1135 + </section>
1136 + )}
1137 + {page === 'review' && workspace && diff && (
1138 + <section>
1139 + <button
1140 + className="button quiet back-button"
1141 + type="button"
1142 + disabled={!!busy}
1143 + onClick={() => setPage('editor')}
1144 + >
1145 + <Icon name="arrow" />
1146 + بازگشت به ویرایشگر
1147 + </button>
1148 + {workspaceHeader}
1149 + <div className="screen-heading">
1150 + <p className="eyebrow">قبل از ثبت</p>
1151 + <h2 className="screen-title">یک بار دیگر، با دقت.</h2>
1152 + <p className="screen-description">
1153 + فایل‌ها، تفاوت‌ها و پیام Commit را بررسی کن. تأیید نهایی در
1154 + تلگرام انجام می‌شود.
1155 + </p>
1156 + </div>
1157 + <div className="review-panel">
1158 + <div className="review-summary">
1159 + <div className="review-facts">
1160 + <div className="review-fact">
1161 + <span>مخزن</span>
1162 + <strong dir="ltr">{workspace.repoFullName}</strong>
1163 + </div>
1164 + <div className="review-fact">
1165 + <span>شاخه مبنا</span>
1166 + <strong dir="ltr">{workspace.baseBranch}</strong>
1167 + </div>
1168 + <div className="review-fact">
1169 + <span>شاخه جدید</span>
1170 + <strong dir="ltr">nexa/edit-{workspace.id}</strong>
1171 + </div>
1172 + <div className="review-fact">
1173 + <span>نسخه مبنا</span>
1174 + <strong dir="ltr">
1175 + {workspace.baseHeadSha.slice(0, 10)}
1176 + </strong>
1177 + </div>
1178 + </div>
1179 + <ul className="review-files">
1180 + {workspace.files.map((file) => (
1181 + <li key={file.path}>
1182 + <Icon name="file" />
1183 + <bdi>{file.path}</bdi>
1184 + <span className="badge">ویرایش</span>
1185 + </li>
1186 + ))}
1187 + </ul>
1188 + </div>
1189 + <div className="diff-toolbar">
1190 + <strong>تفاوت تغییرات · Diff</strong>
1191 + <span>
1192 + <bdi>+{number(diff.additions)}</bdi> /{' '}
1193 + <bdi>−{number(diff.deletions)}</bdi>
1194 + </span>
1195 + </div>
1196 + <pre
1197 + className="diff-view"
1198 + dir="ltr"
1199 + tabIndex={0}
1200 + aria-label="تفاوت تغییرات"
1201 + >
1202 + {diff.text
1203 + ? diff.text.split('\n').map((line, index) => (
1204 + <span
1205 + key={index}
1206 + className={`diff-line ${line.startsWith('+++') || line.startsWith('---') || line.startsWith('@@') ? 'hunk' : line.startsWith('+') ? 'addition' : line.startsWith('-') ? 'deletion' : 'context'}`}
1207 + >
1208 + {line}
1209 + {'\n'}
1210 + </span>
1211 + ))
1212 + : 'تغییری برای ثبت وجود ندارد.'}
1213 + </pre>
1214 + </div>
1215 + {!reviewSnapshot && (
1216 + <div className="notice warning" role="alert">
1217 + <p>
1218 + تغییرات از زمان بازبینی عوض شده‌اند. آخرین نسخه را دریافت
1219 + و Diff تازه را بررسی کن.
1220 + </p>
1221 + <button
1222 + className="button secondary"
1223 + type="button"
1224 + disabled={!!busy}
1225 + onClick={() => void review(true)}
1226 + >
1227 + بارگیری و بازبینی تازه
1228 + </button>
1229 + </div>
1230 + )}
1231 + {diff.truncated && (
1232 + <div className="notice warning" role="alert">
1233 + Diff کامل نیست. برای بازبینی امن، تغییرات را کوچک‌تر کن.
1234 + </div>
1235 + )}
1236 + <label className="field">
1237 + <span>پیام Commit</span>
1238 + <input
1239 + className="text-input"
1240 + dir="auto"
1241 + aria-label="پیام Commit"
1242 + value={message}
1243 + disabled={!!busy}
1244 + autoComplete="off"
1245 + placeholder="مثلاً: اصلاح عنوان صفحه اصلی"
1246 + onChange={(event) => setMessage(event.target.value)}
1247 + />
1248 + <span className="field-help">
1249 + در یک جمله توضیح بده چه چیزی تغییر کرده است. حداکثر ۱۲۰
1250 + نویسه.
1251 + </span>
1252 + </label>
1253 + {chars(message.trim()) > 120 && (
1254 + <p className="notice warning" role="alert">
1255 + پیام را به ۱۲۰ نویسه یا کمتر کوتاه کن.
1256 + </p>
1257 + )}
1258 + <div className="sticky-actions">
1259 + <button
1260 + className="button primary"
1261 + type="button"
1262 + disabled={
1263 + !!busy ||
1264 + !message.trim() ||
1265 + chars(message.trim()) > 120 ||
1266 + !reviewSnapshot ||
1267 + diff.truncated ||
1268 + diff.additions + diff.deletions === 0
1269 + }
1270 + onClick={() => void requestApproval()}
1271 + >
1272 + <Icon name="lock" />
1273 + درخواست تأیید امن
1274 + </button>
1275 + <span className="field-help">
1276 + این دکمه درخواست تأیید می‌فرستد؛ Commit پس از تأیید تو در
1277 + تلگرام ثبت می‌شود.
1278 + </span>
1279 + </div>
1280 + </section>
1281 + )}
1282 + {page === 'approval' &&
1283 + workspace &&
1284 + (approval ||
1285 + ['COMMITTED', 'COMMITTING'].includes(workspace.state)) && (
1286 + <section className="approval-panel">
1287 + <span className="brand-mark">
1288 + <Icon
1289 + name={workspace.state === 'COMMITTED' ? 'check' : 'lock'}
1290 + />
1291 + </span>
1292 + <p className="eyebrow">
1293 + {workspace.state === 'COMMITTED'
1294 + ? 'نتیجه دریافت‌شده از سرور'
1295 + : approval
1296 + ? 'یک گام تا ثبت تغییرات'
1297 + : 'وضعیت دریافت‌شده از سرور'}
1298 + </p>
1299 + <h1 className="screen-title">
1300 + {workspace.state === 'COMMITTED'
1301 + ? 'Commit ثبت شد'
1302 + : approval
1303 + ? 'درخواست تأیید به تلگرام فرستاده شد'
1304 + : 'ثبت تغییرات در حال بررسی است'}
1305 + </h1>
1306 + <p className="screen-description">
1307 + {workspace.state === 'COMMITTED'
1308 + ? 'نتیجه فضای کاری تأیید می‌کند که تغییرات روی شاخه جدید ثبت شده‌اند.'
1309 + : approval
1310 + ? 'به گفت‌وگو با ربات برگرد و درخواست امضاشده را بررسی و تأیید کن. تا آن زمان، تغییری در GitHub ثبت نمی‌شود.'
1311 + : 'نتیجه نهایی هنوز دریافت نشده است. وضعیت را دوباره از سرور بررسی کن.'}
1312 + </p>
1313 + <div className="approval-target">
1314 + <strong dir="ltr">{workspace.repoFullName}</strong>
1315 + <span dir="ltr">
1316 + {workspace.result?.branch ||
1317 + approval?.targetBranch ||
1318 + `nexa/edit-${workspace.id}`}
1319 + </span>
1320 + {workspace.result?.commitSha && (
1321 + <code>{workspace.result.commitSha.slice(0, 12)}</code>
1322 + )}
1323 + </div>
1324 + {workspace.state === 'COMMITTED' &&
1325 + workspace.result?.commitSha && (
1326 + <a
1327 + className="button primary result-link"
1328 + href={`https://github.com/${workspace.repoFullName.split('/').map(encodeURIComponent).join('/')}/commit/${encodeURIComponent(workspace.result.commitSha)}`}
1329 + target="_blank"
1330 + rel="noopener noreferrer"
1331 + >
1332 + مشاهده Commit در GitHub
1333 + </a>
1334 + )}
1335 + <div className="action-row">
1336 + <button
1337 + className="button primary close-action"
1338 + type="button"
1339 + disabled={!!busy}
1340 + onClick={() => telegram?.close?.()}
1341 + >
1342 + بستن و رفتن به تلگرام
1343 + </button>
1344 + <button
1345 + className="button secondary"
1346 + type="button"
1347 + disabled={!!busy}
1348 + onClick={() => void refreshWorkspace()}
1349 + >
1350 + بررسی نتیجه
1351 + </button>
1352 + </div>
1353 + {workspace.state !== 'COMMITTED' && (
1354 + <button
1355 + className="button quiet small danger"
1356 + type="button"
1357 + disabled={!!busy}
1358 + onClick={() =>
1359 + setDiscardAction(() => () => void cancelWorkspace())
1360 + }
1361 + >
1362 + لغو فضای کاری
1363 + </button>
1364 + )}
1365 + </section>
1366 + )}
1367 + </>
1368 + )}
1369 + </main>
1370 + <footer className="app-footer">
1371 + <span>Nexa Studio</span>
1372 + <span>تغییر با اختیار تو.</span>
1373 + </footer>
1374 + {discardAction && (
1375 + <div className="modal-backdrop">
1376 + <section
1377 + className="dialog"
1378 + role="dialog"
1379 + aria-modal="true"
1380 + aria-labelledby="discard-title"
1381 + aria-describedby="discard-description"
1382 + >
1383 + <h2 id="discard-title">ادامه می‌دهی؟</h2>
1384 + <p id="discard-description">
1385 + {hasUnsaved
1386 + ? 'بخشی از تغییرات هنوز ذخیره نشده است. با ادامه، این تغییرات از ویرایشگر کنار گذاشته می‌شوند.'
1387 + : 'با لغو فضای کاری، این پیش‌نویس دیگر قابل ادامه نیست.'}
1388 + </p>
1389 + <div className="dialog-actions">
1390 + <button
1391 + className="button secondary"
1392 + type="button"
1393 + autoFocus
1394 + onClick={() => setDiscardAction(null)}
1395 + >
1396 + ادامه ویرایش
1397 + </button>
1398 + <button
1399 + className="button danger"
1400 + type="button"
1401 + onClick={() => {
1402 + const action = discardAction;
1403 + setDiscardAction(null);
1404 + action();
1405 + }}
1406 + >
1407 + کنار گذاشتن و ادامه
1408 + </button>
1409 + </div>
1410 + </section>
1411 + </div>
1412 + )}
1413 + </div>
1414 + );
1415 +}
web/src/CodeEditor.tsx new
+191
@@ -0,0 +1,191 @@
1 +import { useEffect, useRef } from 'react';
2 +import { Compartment, EditorState } from '@codemirror/state';
3 +import {
4 + EditorView,
5 + highlightActiveLine,
6 + highlightActiveLineGutter,
7 + lineNumbers,
8 + keymap,
9 + drawSelection
10 +} from '@codemirror/view';
11 +import {
12 + defaultKeymap,
13 + history,
14 + historyKeymap,
15 + indentWithTab
16 +} from '@codemirror/commands';
17 +import {
18 + bracketMatching,
19 + defaultHighlightStyle,
20 + syntaxHighlighting
21 +} from '@codemirror/language';
22 +import { javascript } from '@codemirror/lang-javascript';
23 +import { json } from '@codemirror/lang-json';
24 +import { css } from '@codemirror/lang-css';
25 +import { html } from '@codemirror/lang-html';
26 +import { search, searchKeymap, openSearchPanel } from '@codemirror/search';
27 +
28 +function languageFor(path: string) {
29 + if (/\.(jsx?|tsx?|mjs|cjs)$/i.test(path))
30 + return javascript({
31 + typescript: /\.tsx?$/i.test(path),
32 + jsx: /\.[jt]sx$/i.test(path)
33 + });
34 + if (/\.json$/i.test(path)) return json();
35 + if (/\.css$/i.test(path)) return css();
36 + if (/\.(html?|svg)$/i.test(path)) return html();
37 + return [];
38 +}
39 +export function CodeEditor({
40 + value,
41 + path,
42 + readOnly,
43 + fontSize,
44 + onChange
45 +}: {
46 + value: string;
47 + path: string;
48 + readOnly: boolean;
49 + fontSize: number;
50 + onChange: (value: string) => void;
51 +}) {
52 + const host = useRef<HTMLDivElement>(null);
53 + const editor = useRef<EditorView | null>(null);
54 + const callback = useRef(onChange);
55 + const editable = useRef(new Compartment());
56 + const typography = useRef(new Compartment());
57 + callback.current = onChange;
58 + useEffect(() => {
59 + if (!host.current) return;
60 + const nonce =
61 + document.querySelector<HTMLMetaElement>('meta[name="csp-nonce"]')
62 + ?.content || '';
63 + const view = new EditorView({
64 + parent: host.current,
65 + state: EditorState.create({
66 + doc: value,
67 + extensions: [
68 + EditorView.cspNonce.of(nonce),
69 + EditorState.phrases.of({
70 + 'Find': 'جست‌وجو',
71 + 'Replace': 'جایگزین',
72 + 'next': 'بعدی',
73 + 'previous': 'قبلی',
74 + 'all': 'همه',
75 + 'match case': 'حساس به حروف',
76 + 'regexp': 'عبارت منظم',
77 + 'by word': 'واژه کامل',
78 + 'replace': 'جایگزینی',
79 + 'replace all': 'جایگزینی همه',
80 + 'close': 'بستن',
81 + 'Go to line': 'رفتن به خط',
82 + 'go': 'برو',
83 + 'current match': 'نتیجه فعلی',
84 + 'on line': 'در خط',
85 + 'replaced match on line $': 'نتیجه خط $ جایگزین شد',
86 + 'replaced $ matches': '$ نتیجه جایگزین شد'
87 + }),
88 + lineNumbers(),
89 + highlightActiveLineGutter(),
90 + highlightActiveLine(),
91 + drawSelection(),
92 + history(),
93 + bracketMatching(),
94 + search({ top: true }),
95 + syntaxHighlighting(defaultHighlightStyle),
96 + languageFor(path),
97 + keymap.of([
98 + indentWithTab,
99 + ...defaultKeymap,
100 + ...historyKeymap,
101 + ...searchKeymap
102 + ]),
103 + EditorView.contentAttributes.of({
104 + 'aria-label': `ویرایش ${path}`,
105 + 'dir': 'ltr',
106 + 'spellcheck': 'false',
107 + 'autocapitalize': 'off',
108 + 'autocomplete': 'off'
109 + }),
110 + editable.current.of(EditorState.readOnly.of(readOnly)),
111 + typography.current.of(
112 + EditorView.theme({ '&': { fontSize: `${fontSize}px` } })
113 + ),
114 + EditorView.theme(
115 + {
116 + '&': {
117 + color: 'var(--text)',
118 + backgroundColor: 'var(--page)',
119 + height: '100%',
120 + direction: 'ltr'
121 + },
122 + '.cm-content': {
123 + fontFamily:
124 + 'ui-monospace, SFMono-Regular, Menlo, Consolas, monospace',
125 + padding: '18px 0',
126 + minHeight: '320px',
127 + caretColor: 'var(--accent)'
128 + },
129 + '.cm-scroller': { overflow: 'auto', lineHeight: '1.8' },
130 + '.cm-gutters': {
131 + color: 'var(--muted)',
132 + backgroundColor: 'var(--page)',
133 + borderRight: '1px solid var(--line)'
134 + },
135 + '.cm-activeLine, .cm-activeLineGutter': {
136 + backgroundColor: 'var(--soft)'
137 + },
138 + '.cm-selectionBackground, &.cm-focused .cm-selectionBackground': {
139 + backgroundColor: '#305a6e80'
140 + },
141 + '.cm-cursor': { borderLeftColor: 'var(--accent)' },
142 + '.cm-panels': {
143 + backgroundColor: 'var(--surface)',
144 + color: 'var(--text)'
145 + },
146 + '.cm-search input': {
147 + color: 'var(--text)',
148 + backgroundColor: 'var(--page)',
149 + border: '1px solid var(--line)'
150 + }
151 + },
152 + { dark: true }
153 + ),
154 + EditorView.updateListener.of((update) => {
155 + if (update.docChanged)
156 + callback.current(update.state.doc.toString());
157 + })
158 + ]
159 + })
160 + });
161 + editor.current = view;
162 + return () => {
163 + editor.current = null;
164 + view.destroy();
165 + };
166 + // A tab owns its own history. Value changes are applied without recreating the editor.
167 + }, [path]);
168 + useEffect(() => {
169 + const view = editor.current;
170 + if (view && view.state.doc.toString() !== value)
171 + view.dispatch({
172 + changes: { from: 0, to: view.state.doc.length, insert: value }
173 + });
174 + }, [value]);
175 + useEffect(() => {
176 + editor.current?.dispatch({
177 + effects: [
178 + editable.current.reconfigure(EditorState.readOnly.of(readOnly)),
179 + typography.current.reconfigure(
180 + EditorView.theme({ '&': { fontSize: `${fontSize}px` } })
181 + )
182 + ]
183 + });
184 + }, [readOnly, fontSize]);
185 + return <div className="editor-host" ref={host} />;
186 +}
187 +export function searchEditor() {
188 + const element = document.querySelector<HTMLElement>('.cm-editor');
189 + const view = element ? EditorView.findFromDOM(element) : null;
190 + if (view) openSearchPanel(view);
191 +}
web/src/api.ts new
+46
@@ -0,0 +1,46 @@
1 +export class ApiError extends Error {
2 + constructor(
3 + public status: number,
4 + message: string
5 + ) {
6 + super(message);
7 + }
8 +}
9 +export function createApi(initData: string, fetcher: typeof fetch) {
10 + return async function request<T>(
11 + path: string,
12 + options: RequestInit = {}
13 + ): Promise<T> {
14 + if (!initData)
15 + throw new ApiError(403, 'Nexa Studio را از داخل تلگرام باز کن.');
16 + const response = await fetcher(`/api/v1/studio${path}`, {
17 + ...options,
18 + credentials: 'same-origin',
19 + cache: 'no-store',
20 + headers: {
21 + 'x-telegram-init-data': initData,
22 + ...(options.body ? { 'content-type': 'application/json' } : {}),
23 + ...options.headers
24 + }
25 + });
26 + let body;
27 + try {
28 + body = await response.json();
29 + } catch {
30 + throw new ApiError(
31 + response.status,
32 + 'پاسخ سرویس قابل خواندن نیست. دوباره تلاش کن.'
33 + );
34 + }
35 + if (!response.ok || body.ok === false) {
36 + const message =
37 + typeof body.error === 'string' && /[\u0600-\u06FF]/.test(body.error)
38 + ? body.error
39 + : response.status === 403
40 + ? 'دسترسی تأیید نشد. برنامه را دوباره از تلگرام باز کن.'
41 + : 'درخواست انجام نشد. دوباره تلاش کن.';
42 + throw new ApiError(response.status, message);
43 + }
44 + return body as T;
45 + };
46 +}
web/src/main.tsx new
+10
@@ -0,0 +1,10 @@
1 +import { StrictMode } from 'react';
2 +import { createRoot } from 'react-dom/client';
3 +import { App } from './App.js';
4 +import './styles.css';
5 +
6 +createRoot(document.getElementById('root')!).render(
7 + <StrictMode>
8 + <App />
9 + </StrictMode>
10 +);
web/src/styles.css new
+1084
@@ -0,0 +1,1084 @@
1 +@charset "UTF-8";
2 +
3 +:root {
4 + font-family: Vazirmatn, Tahoma, Arial, sans-serif;
5 + color: var(--tg-theme-text-color, #edf3f9);
6 + background: var(--tg-theme-bg-color, #10161e);
7 + font-synthesis: none;
8 + text-rendering: optimizeLegibility;
9 + -webkit-font-smoothing: antialiased;
10 + -moz-osx-font-smoothing: grayscale;
11 + --page: var(--tg-theme-bg-color, #10161e);
12 + --surface: var(--tg-theme-secondary-bg-color, #18212b);
13 + --text: var(--tg-theme-text-color, #edf3f9);
14 + --muted: var(--tg-theme-hint-color, #aab9c8);
15 + --accent: var(--tg-theme-button-color, #6ce2bc);
16 + --accent-text: var(--tg-theme-button-text-color, #09251d);
17 + --line: color-mix(in srgb, var(--text) 12%, transparent);
18 + --soft: color-mix(in srgb, var(--text) 5%, var(--surface));
19 + --success: #7bdbad;
20 + --warning: #f4cf83;
21 + --error: #ffaca9;
22 + --radius: 16px;
23 +}
24 +
25 +* {
26 + box-sizing: border-box;
27 +}
28 +body {
29 + margin: 0;
30 + min-width: 280px;
31 +}
32 +button,
33 +input,
34 +textarea,
35 +select {
36 + font: inherit;
37 +}
38 +button,
39 +a,
40 +input,
41 +textarea,
42 +select {
43 + -webkit-tap-highlight-color: transparent;
44 +}
45 +button,
46 +a {
47 + touch-action: manipulation;
48 +}
49 +button {
50 + cursor: pointer;
51 +}
52 +button:disabled {
53 + cursor: not-allowed;
54 + opacity: 0.45;
55 +}
56 +button,
57 +input,
58 +textarea,
59 +select {
60 + border-radius: 10px;
61 +}
62 +button:focus-visible,
63 +a:focus-visible,
64 +input:focus-visible,
65 +textarea:focus-visible,
66 +select:focus-visible {
67 + outline: 3px solid var(--accent);
68 + outline-offset: 3px;
69 +}
70 +a {
71 + color: var(--accent);
72 + text-underline-offset: 4px;
73 +}
74 +svg {
75 + width: 20px;
76 + height: 20px;
77 + flex-shrink: 0;
78 + vertical-align: middle;
79 +}
80 +h1,
81 +h2,
82 +h3,
83 +p {
84 + margin: 0;
85 +}
86 +pre,
87 +code {
88 + font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
89 +}
90 +pre,
91 +.cm-editor,
92 +.inline-code,
93 +.approval-target {
94 + direction: ltr;
95 + unicode-bidi: isolate;
96 +}
97 +.app-shell {
98 + min-height: 100dvh;
99 + padding-bottom: env(safe-area-inset-bottom, 0px);
100 +}
101 +.topbar {
102 + min-height: 82px;
103 + padding: 18px max(20px, calc((100vw - 1100px) / 2));
104 + display: flex;
105 + align-items: center;
106 + justify-content: space-between;
107 + gap: 16px;
108 + border-bottom: 1px solid var(--line);
109 + background: var(--page);
110 +}
111 +.brand {
112 + display: flex;
113 + align-items: center;
114 + gap: 11px;
115 + min-width: 0;
116 +}
117 +.brand-mark {
118 + width: 39px;
119 + height: 39px;
120 + display: grid;
121 + place-items: center;
122 + color: var(--accent);
123 + background: color-mix(in srgb, var(--accent) 11%, transparent);
124 + border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
125 + border-radius: 13px;
126 + font:
127 + 700 22px/1 Arial,
128 + sans-serif;
129 +}
130 +.brand-mark svg {
131 + width: 23px;
132 + height: 23px;
133 +}
134 +.brand-name {
135 + display: block;
136 + font-size: 16px;
137 + font-weight: 700;
138 + letter-spacing: -0.3px;
139 +}
140 +.brand-subtitle {
141 + display: block;
142 + margin-top: 3px;
143 + color: var(--muted);
144 + font-size: 11px;
145 +}
146 +.user-pill {
147 + padding: 8px 11px;
148 + background: var(--soft);
149 + border: 1px solid var(--line);
150 + border-radius: 999px;
151 + font-size: 12px;
152 + max-width: 38%;
153 + overflow: hidden;
154 + text-overflow: ellipsis;
155 + white-space: nowrap;
156 +}
157 +.app-main {
158 + width: min(100% - 40px, 1100px);
159 + margin: 0 auto;
160 + padding: 32px 0 20px;
161 +}
162 +.screen-heading {
163 + margin-bottom: 24px;
164 +}
165 +.eyebrow {
166 + display: flex;
167 + align-items: center;
168 + gap: 7px;
169 + color: var(--accent);
170 + font-size: 11px;
171 + font-weight: 700;
172 + margin-bottom: 10px;
173 +}
174 +.screen-title {
175 + font-size: clamp(23px, 5vw, 32px);
176 + line-height: 1.65;
177 + font-weight: 700;
178 + letter-spacing: -0.8px;
179 +}
180 +.screen-description {
181 + color: var(--muted);
182 + font-size: 13px;
183 + line-height: 2;
184 + margin-top: 8px;
185 + max-width: 650px;
186 +}
187 +.button,
188 +.icon-button,
189 +.back-button {
190 + min-height: 44px;
191 + border: 1px solid transparent;
192 + display: inline-flex;
193 + align-items: center;
194 + justify-content: center;
195 + gap: 8px;
196 + padding: 10px 16px;
197 + font-size: 13px;
198 + font-weight: 700;
199 + line-height: 1.6;
200 + text-decoration: none;
201 + transition:
202 + background-color 0.15s,
203 + border-color 0.15s,
204 + opacity 0.15s;
205 +}
206 +.button.primary {
207 + background: var(--accent);
208 + color: var(--accent-text);
209 +}
210 +.button.primary:hover:not(:disabled) {
211 + filter: brightness(1.07);
212 +}
213 +.button.secondary {
214 + color: var(--text);
215 + background: var(--soft);
216 + border-color: var(--line);
217 +}
218 +.button.secondary:hover:not(:disabled) {
219 + border-color: color-mix(in srgb, var(--text) 30%, transparent);
220 +}
221 +.button.quiet,
222 +.back-button {
223 + color: var(--muted);
224 + background: transparent;
225 +}
226 +.button.quiet:hover:not(:disabled),
227 +.back-button:hover:not(:disabled) {
228 + color: var(--text);
229 + background: var(--soft);
230 +}
231 +.button.danger {
232 + color: var(--error);
233 + background: color-mix(in srgb, var(--error) 8%, transparent);
234 + border-color: color-mix(in srgb, var(--error) 23%, transparent);
235 +}
236 +.button.small {
237 + padding-inline: 12px;
238 + font-size: 12px;
239 +}
240 +.icon-button {
241 + width: 44px;
242 + min-width: 44px;
243 + padding: 10px;
244 + background: var(--soft);
245 + border-color: var(--line);
246 + color: var(--text);
247 +}
248 +.action-row {
249 + display: flex;
250 + gap: 10px;
251 + align-items: center;
252 + flex-wrap: wrap;
253 +}
254 +.back-button {
255 + padding-inline: 0 8px;
256 + margin-bottom: 12px;
257 + font-weight: 400;
258 +}
259 +.loading-state,
260 +.empty-state {
261 + padding: 42px 20px;
262 + display: flex;
263 + flex-direction: column;
264 + align-items: center;
265 + text-align: center;
266 + gap: 14px;
267 + color: var(--muted);
268 + line-height: 1.9;
269 + font-size: 13px;
270 +}
271 +.empty-state {
272 + background: var(--surface);
273 + border: 1px solid var(--line);
274 + border-radius: var(--radius);
275 +}
276 +.empty-state svg {
277 + width: 32px;
278 + height: 32px;
279 + color: var(--accent);
280 +}
281 +.empty-state h2,
282 +.empty-state h3 {
283 + color: var(--text);
284 + font-size: 16px;
285 +}
286 +.spinner {
287 + display: inline-block;
288 + width: 22px;
289 + height: 22px;
290 + border: 2px solid var(--line);
291 + border-top-color: var(--accent);
292 + border-radius: 50%;
293 + animation: spin 0.8s linear infinite;
294 +}
295 +@keyframes spin {
296 + to {
297 + transform: rotate(360deg);
298 + }
299 +}
300 +.notice {
301 + margin: 16px 0;
302 + padding: 15px 17px;
303 + border: 1px solid var(--line);
304 + border-radius: 12px;
305 + font-size: 12px;
306 + line-height: 2;
307 + color: var(--muted);
308 + background: var(--surface);
309 + overflow-wrap: anywhere;
310 +}
311 +.notice-title {
312 + color: var(--text);
313 + font-weight: 700;
314 + margin-bottom: 5px;
315 +}
316 +.notice.error {
317 + color: var(--error);
318 + border-color: color-mix(in srgb, var(--error) 26%, transparent);
319 + background: color-mix(in srgb, var(--error) 5%, var(--page));
320 +}
321 +.notice.success {
322 + color: var(--success);
323 + border-color: color-mix(in srgb, var(--success) 25%, transparent);
324 + background: color-mix(in srgb, var(--success) 5%, var(--page));
325 +}
326 +.notice.warning {
327 + color: var(--warning);
328 + border-color: color-mix(in srgb, var(--warning) 26%, transparent);
329 + background: color-mix(in srgb, var(--warning) 5%, var(--page));
330 +}
331 +.notice.info {
332 + border-color: color-mix(in srgb, var(--accent) 22%, transparent);
333 +}
334 +.notice .action-row {
335 + margin-top: 10px;
336 +}
337 +.repo-list {
338 + display: grid;
339 + gap: 12px;
340 +}
341 +.repo-card {
342 + display: flex;
343 + align-items: flex-start;
344 + gap: 14px;
345 + width: 100%;
346 + min-height: 114px;
347 + padding: 20px;
348 + text-align: start;
349 + color: var(--text);
350 + background: var(--surface);
351 + border: 1px solid var(--line);
352 + border-radius: var(--radius);
353 + transition:
354 + border-color 0.15s,
355 + background-color 0.15s;
356 +}
357 +.repo-card:hover {
358 + border-color: color-mix(in srgb, var(--accent) 45%, transparent);
359 + background: color-mix(in srgb, var(--accent) 3%, var(--surface));
360 +}
361 +.repo-icon {
362 + display: grid;
363 + place-items: center;
364 + color: var(--accent);
365 + background: var(--soft);
366 + width: 42px;
367 + height: 42px;
368 + border: 1px solid var(--line);
369 + border-radius: 12px;
370 + flex-shrink: 0;
371 +}
372 +.repo-copy {
373 + flex: 1;
374 + min-width: 0;
375 +}
376 +.repo-name {
377 + display: block;
378 + direction: ltr;
379 + unicode-bidi: isolate;
380 + text-align: end;
381 + font:
382 + 600 14px/1.6 'SFMono-Regular',
383 + Consolas,
384 + monospace;
385 + overflow-wrap: anywhere;
386 +}
387 +.repo-description {
388 + display: block;
389 + color: var(--muted);
390 + font-size: 12px;
391 + line-height: 1.9;
392 + margin-top: 7px;
393 + overflow-wrap: anywhere;
394 +}
395 +.repo-meta {
396 + display: flex;
397 + gap: 8px;
398 + flex-wrap: wrap;
399 + align-items: center;
400 + color: var(--muted);
401 + font-size: 10px;
402 + margin-top: 12px;
403 +}
404 +.badge {
405 + display: inline-flex;
406 + align-items: center;
407 + gap: 5px;
408 + padding: 3px 8px;
409 + border: 1px solid var(--line);
410 + border-radius: 6px;
411 + font-size: 10px;
412 + line-height: 1.7;
413 + color: var(--muted);
414 +}
415 +.breadcrumb {
416 + display: flex;
417 + flex-wrap: wrap;
418 + align-items: center;
419 + gap: 4px;
420 + font-size: 12px;
421 + margin-bottom: 14px;
422 + overflow-wrap: anywhere;
423 +}
424 +.breadcrumb button {
425 + min-height: 44px;
426 + padding: 7px 9px;
427 + background: transparent;
428 + border: 0;
429 + color: var(--muted);
430 +}
431 +.breadcrumb button:hover {
432 + color: var(--accent);
433 + background: var(--soft);
434 +}
435 +.browser-panel,
436 +.editor-panel,
437 +.review-panel {
438 + border: 1px solid var(--line);
439 + border-radius: var(--radius);
440 + background: var(--surface);
441 + overflow: hidden;
442 +}
443 +.panel-heading {
444 + min-height: 58px;
445 + display: flex;
446 + align-items: center;
447 + justify-content: space-between;
448 + gap: 12px;
449 + padding: 14px 18px;
450 + border-bottom: 1px solid var(--line);
451 + font-size: 12px;
452 + font-weight: 700;
453 +}
454 +.panel-heading p {
455 + font-weight: 400;
456 + color: var(--muted);
457 + font-size: 11px;
458 +}
459 +.tree-list {
460 + display: flex;
461 + flex-direction: column;
462 + padding: 6px;
463 +}
464 +.tree-row {
465 + display: flex;
466 + align-items: center;
467 + gap: 11px;
468 + width: 100%;
469 + min-height: 58px;
470 + padding: 10px 12px;
471 + text-align: start;
472 + border: 1px solid transparent;
473 + border-radius: 9px;
474 + color: var(--text);
475 + background: transparent;
476 +}
477 +.tree-row:hover {
478 + background: var(--soft);
479 + border-color: var(--line);
480 +}
481 +.tree-row:disabled {
482 + opacity: 0.6;
483 +}
484 +.tree-icon {
485 + color: var(--muted);
486 + flex-shrink: 0;
487 +}
488 +.tree-row:has(.tree-icon[data-type='dir']) .tree-icon {
489 + color: var(--accent);
490 +}
491 +.tree-name {
492 + flex: 1;
493 + min-width: 0;
494 + overflow-wrap: anywhere;
495 + direction: ltr;
496 + unicode-bidi: isolate;
497 + text-align: end;
498 + font:
499 + 12px/1.8 'SFMono-Regular',
500 + Consolas,
501 + monospace;
502 +}
503 +.tree-detail {
504 + color: var(--muted);
505 + font-size: 10px;
506 + white-space: nowrap;
507 +}
508 +.workspace-header {
509 + margin-bottom: 19px;
510 + display: flex;
511 + justify-content: space-between;
512 + gap: 14px;
513 + align-items: flex-start;
514 + flex-wrap: wrap;
515 +}
516 +.workspace-title {
517 + font-size: 22px;
518 + font-weight: 700;
519 + line-height: 1.7;
520 +}
521 +.workspace-meta {
522 + margin-top: 7px;
523 + font-size: 11px;
524 + line-height: 1.9;
525 + color: var(--muted);
526 + display: flex;
527 + flex-wrap: wrap;
528 + align-items: center;
529 + gap: 6px 12px;
530 + overflow-wrap: anywhere;
531 +}
532 +.workspace-layout {
533 + display: grid;
534 + grid-template-columns: minmax(0, 1fr);
535 + gap: 16px;
536 + align-items: start;
537 +}
538 +.editor-toolbar {
539 + display: flex;
540 + align-items: center;
541 + justify-content: space-between;
542 + flex-wrap: wrap;
543 + gap: 9px;
544 + padding: 11px 14px;
545 + border-bottom: 1px solid var(--line);
546 +}
547 +.editor-settings {
548 + display: flex;
549 + align-items: center;
550 + flex-wrap: wrap;
551 + gap: 8px;
552 +}
553 +.select-control,
554 +.font-control {
555 + min-height: 44px;
556 + color: var(--muted);
557 + background: var(--page);
558 + border: 1px solid var(--line);
559 + padding: 7px 10px;
560 + font-size: 11px;
561 +}
562 +.font-control {
563 + max-width: 90px;
564 +}
565 +.file-tabs {
566 + display: flex;
567 + gap: 4px;
568 + overflow-x: auto;
569 + overscroll-behavior-x: contain;
570 + padding: 7px 8px 0;
571 + border-bottom: 1px solid var(--line);
572 + scrollbar-width: thin;
573 +}
574 +.file-tab {
575 + min-height: 46px;
576 + border: 0;
577 + border-bottom: 2px solid transparent;
578 + border-radius: 7px 7px 0 0;
579 + color: var(--muted);
580 + background: transparent;
581 + padding: 10px 12px;
582 + font:
583 + 12px/1.8 'SFMono-Regular',
584 + Consolas,
585 + monospace;
586 + direction: ltr;
587 + unicode-bidi: isolate;
588 + white-space: nowrap;
589 +}
590 +.file-tab.active {
591 + color: var(--text);
592 + background: var(--page);
593 + border-bottom-color: var(--accent);
594 +}
595 +.file-tab.dirty::after {
596 + content: '';
597 + display: inline-block;
598 + width: 6px;
599 + height: 6px;
600 + margin-left: 7px;
601 + background: var(--warning);
602 + border-radius: 50%;
603 + vertical-align: middle;
604 +}
605 +.editor-host {
606 + overflow: hidden;
607 + background: var(--page);
608 +}
609 +.cm-editor {
610 + min-height: 320px;
611 + text-align: left;
612 + background: var(--page);
613 +}
614 +.cm-editor .cm-scroller {
615 + overflow: auto;
616 + min-height: 320px;
617 + max-height: min(65dvh, 720px);
618 + font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
619 + line-height: 1.75;
620 +}
621 +.cm-editor.cm-focused {
622 + outline: none;
623 +}
624 +.cm-editor .cm-content {
625 + padding: 18px 0;
626 + caret-color: var(--accent);
627 +}
628 +.cm-editor .cm-gutters {
629 + background: var(--surface);
630 + color: var(--muted);
631 + border-inline-end: 1px solid var(--line);
632 +}
633 +.cm-editor .cm-activeLineGutter {
634 + background: var(--soft);
635 + color: var(--text);
636 +}
637 +.cm-editor .cm-activeLine {
638 + background: color-mix(in srgb, var(--text) 3%, transparent);
639 +}
640 +.cm-editor .cm-cursor {
641 + border-left-color: var(--accent);
642 +}
643 +.cm-editor .cm-selectionBackground,
644 +.cm-editor.cm-focused .cm-selectionBackground {
645 + background: color-mix(in srgb, var(--accent) 24%, transparent);
646 +}
647 +.cm-editor .cm-panels {
648 + background: var(--surface);
649 + color: var(--text);
650 + border-color: var(--line);
651 +}
652 +.cm-editor .cm-search {
653 + direction: ltr;
654 + display: flex;
655 + flex-wrap: wrap;
656 + align-items: center;
657 + gap: 5px;
658 + padding: 10px;
659 +}
660 +.cm-editor .cm-textfield {
661 + min-height: 44px;
662 + max-width: 100%;
663 + background: var(--page);
664 + color: var(--text);
665 + border: 1px solid var(--line);
666 + padding: 6px 9px;
667 +}
668 +.cm-editor .cm-button {
669 + min-height: 44px;
670 + color: var(--text);
671 + background: var(--soft);
672 + border: 1px solid var(--line);
673 + font-size: 12px;
674 + padding: 7px 10px;
675 +}
676 +.cm-editor .cm-search label {
677 + display: inline-flex;
678 + align-items: center;
679 + gap: 5px;
680 + min-height: 44px;
681 +}
682 +.cm-editor .cm-search button[name='close'] {
683 + min-width: 44px;
684 + min-height: 44px;
685 + color: var(--text);
686 +}
687 +.editor-status {
688 + min-height: 45px;
689 + display: flex;
690 + align-items: center;
691 + justify-content: space-between;
692 + flex-wrap: wrap;
693 + gap: 8px 12px;
694 + padding: 11px 14px;
695 + border-top: 1px solid var(--line);
696 + font-size: 10px;
697 + color: var(--muted);
698 +}
699 +.editor-status > span {
700 + display: inline-flex;
701 + align-items: center;
702 + gap: 6px;
703 +}
704 +.status-dot {
705 + display: inline-block;
706 + width: 6px;
707 + height: 6px;
708 + border-radius: 50%;
709 + background: var(--muted);
710 +}
711 +.status-dot.dirty {
712 + background: var(--warning);
713 +}
714 +.status-dot.saved {
715 + background: var(--success);
716 +}
717 +.count-limit {
718 + font-variant-numeric: tabular-nums;
719 + line-height: 1.8;
720 +}
721 +.over-limit {
722 + color: var(--error);
723 +}
724 +.editor-actions {
725 + display: flex;
726 + align-items: center;
727 + justify-content: space-between;
728 + gap: 10px;
729 + flex-wrap: wrap;
730 + padding: 14px;
731 + border-top: 1px solid var(--line);
732 +}
733 +.conflict-panel {
734 + padding: 18px;
735 + border: 1px solid color-mix(in srgb, var(--warning) 38%, transparent);
736 + border-radius: 12px;
737 + background: color-mix(in srgb, var(--warning) 6%, var(--page));
738 + margin-block: 16px;
739 +}
740 +.conflict-panel h2,
741 +.conflict-panel h3 {
742 + color: var(--warning);
743 + font-size: 14px;
744 + margin-bottom: 8px;
745 +}
746 +.conflict-panel p {
747 + color: var(--muted);
748 + font-size: 12px;
749 + line-height: 2;
750 + margin-bottom: 14px;
751 +}
752 +.review-panel {
753 + margin-top: 18px;
754 +}
755 +.review-summary {
756 + padding: 20px;
757 +}
758 +.review-summary h2,
759 +.review-summary h3 {
760 + font-size: 16px;
761 + margin-bottom: 17px;
762 +}
763 +.review-facts {
764 + display: grid;
765 + grid-template-columns: 1fr;
766 + gap: 15px;
767 +}
768 +.review-fact {
769 + min-width: 0;
770 + line-height: 1.8;
771 +}
772 +.review-fact dt,
773 +.review-fact label {
774 + color: var(--muted);
775 + font-size: 10px;
776 + margin-bottom: 5px;
777 + display: block;
778 +}
779 +.review-fact dd {
780 + margin: 0;
781 + font-size: 12px;
782 + overflow-wrap: anywhere;
783 +}
784 +.review-files {
785 + padding: 0;
786 + margin: 18px 0 0;
787 + list-style: none;
788 + display: flex;
789 + flex-wrap: wrap;
790 + gap: 7px;
791 +}
792 +.review-files li {
793 + border: 1px solid var(--line);
794 + border-radius: 6px;
795 + background: var(--page);
796 + padding: 6px 8px;
797 + font-size: 11px;
798 + overflow-wrap: anywhere;
799 +}
800 +.diff-toolbar {
801 + min-height: 54px;
802 + padding: 12px 18px;
803 + display: flex;
804 + justify-content: space-between;
805 + align-items: center;
806 + gap: 10px;
807 + flex-wrap: wrap;
808 + border-top: 1px solid var(--line);
809 + border-bottom: 1px solid var(--line);
810 + font-size: 11px;
811 +}
812 +.diff-toolbar .addition,
813 +.diff-toolbar .deletion {
814 + padding: 3px 7px;
815 + border-radius: 5px;
816 + font-variant-numeric: tabular-nums;
817 +}
818 +.diff-toolbar .addition {
819 + color: var(--success);
820 + background: color-mix(in srgb, var(--success) 8%, transparent);
821 +}
822 +.diff-toolbar .deletion {
823 + color: var(--error);
824 + background: color-mix(in srgb, var(--error) 8%, transparent);
825 +}
826 +.diff-view {
827 + margin: 0;
828 + padding: 12px 0;
829 + overflow: auto;
830 + max-height: 55dvh;
831 + background: var(--page);
832 + color: var(--muted);
833 + text-align: left;
834 + font-size: 11px;
835 + line-height: 1.9;
836 + tab-size: 2;
837 +}
838 +.diff-line {
839 + display: block;
840 + padding: 1px 16px;
841 + min-height: 22px;
842 + white-space: pre;
843 +}
844 +.diff-line.addition {
845 + color: var(--success);
846 + background: color-mix(in srgb, var(--success) 7%, transparent);
847 +}
848 +.diff-line.deletion {
849 + color: var(--error);
850 + background: color-mix(in srgb, var(--error) 7%, transparent);
851 +}
852 +.diff-line.hunk {
853 + color: var(--accent);
854 + background: color-mix(in srgb, var(--accent) 6%, transparent);
855 + padding-block: 6px;
856 + margin-block: 6px;
857 +}
858 +.field {
859 + display: flex;
860 + flex-direction: column;
861 + gap: 8px;
862 + padding: 20px;
863 +}
864 +.field > label {
865 + font-size: 12px;
866 + font-weight: 700;
867 +}
868 +.text-input {
869 + width: 100%;
870 + min-height: 48px;
871 + padding: 12px 13px;
872 + color: var(--text);
873 + background: var(--page);
874 + border: 1px solid var(--line);
875 + font-size: 13px;
876 + resize: vertical;
877 +}
878 +.text-input::placeholder {
879 + color: var(--muted);
880 + opacity: 0.75;
881 +}
882 +.field-help {
883 + color: var(--muted);
884 + font-size: 11px;
885 + line-height: 1.9;
886 +}
887 +.approval-panel {
888 + margin-top: 24px;
889 + border: 1px solid color-mix(in srgb, var(--accent) 26%, transparent);
890 + border-radius: var(--radius);
891 + padding: 24px;
892 + background: color-mix(in srgb, var(--accent) 4%, var(--surface));
893 +}
894 +.approval-panel h2 {
895 + font-size: 20px;
896 + line-height: 1.8;
897 + margin-bottom: 12px;
898 +}
899 +.approval-panel p {
900 + color: var(--muted);
901 + line-height: 2;
902 + font-size: 13px;
903 +}
904 +.approval-panel .action-row {
905 + margin-top: 22px;
906 +}
907 +.approval-target {
908 + display: flex;
909 + flex-direction: column;
910 + gap: 8px;
911 + margin: 14px 0;
912 + color: var(--accent);
913 + overflow-wrap: anywhere;
914 + font-size: 12px;
915 + text-align: start;
916 +}
917 +.sticky-actions {
918 + margin-top: 18px;
919 + padding: 14px 0 max(14px, env(safe-area-inset-bottom, 0px));
920 + display: flex;
921 + align-items: center;
922 + justify-content: space-between;
923 + gap: 12px;
924 + flex-wrap: wrap;
925 +}
926 +.modal-backdrop {
927 + position: fixed;
928 + inset: 0;
929 + z-index: 100;
930 + background: rgb(0 0 0 / 65%);
931 + display: flex;
932 + align-items: center;
933 + justify-content: center;
934 + padding: 20px;
935 + backdrop-filter: blur(3px);
936 +}
937 +.dialog {
938 + width: min(100%, 420px);
939 + padding: 25px;
940 + color: var(--text);
941 + background: var(--surface);
942 + border: 1px solid var(--line);
943 + border-radius: 20px;
944 + box-shadow: 0 20px 80px rgb(0 0 0 / 35%);
945 +}
946 +.dialog h2 {
947 + font-size: 18px;
948 + line-height: 1.8;
949 + margin-bottom: 10px;
950 +}
951 +.dialog p {
952 + font-size: 13px;
953 + color: var(--muted);
954 + line-height: 2;
955 +}
956 +.dialog-actions {
957 + display: flex;
958 + flex-direction: column;
959 + gap: 9px;
960 + margin-top: 22px;
961 +}
962 +.dialog-actions .button {
963 + width: 100%;
964 +}
965 +.close-action {
966 + margin-top: 16px;
967 +}
968 +.result-link {
969 + display: inline-flex;
970 + align-items: center;
971 + gap: 8px;
972 + min-height: 44px;
973 + font-size: 12px;
974 +}
975 +.inline-code {
976 + display: inline-block;
977 + max-width: 100%;
978 + overflow-wrap: anywhere;
979 + font-size: 0.92em;
980 +}
981 +.screen-footer {
982 + margin-top: 18px;
983 + display: flex;
984 + align-items: center;
985 + justify-content: flex-start;
986 + gap: 12px;
987 + flex-wrap: nowrap;
988 + font-size: 12px;
989 + line-height: 1.9;
990 +}
991 +.app-footer {
992 + width: min(100% - 40px, 1100px);
993 + margin-inline: auto;
994 + padding-bottom: 24px;
995 + padding-top: 24px;
996 + margin-top: 24px;
997 + border-top: 1px solid var(--line);
998 + color: var(--muted);
999 + font-size: 10px;
1000 + line-height: 1.9;
1001 + display: flex;
1002 + align-items: center;
1003 + justify-content: space-between;
1004 + gap: 10px;
1005 +}
1006 +
1007 +@media (min-width: 720px) {
1008 + .app-main {
1009 + padding-top: 42px;
1010 + }
1011 + .repo-list {
1012 + grid-template-columns: repeat(2, minmax(0, 1fr));
1013 + }
1014 + .repo-card {
1015 + min-height: 146px;
1016 + }
1017 + .review-facts {
1018 + grid-template-columns: repeat(2, minmax(0, 1fr));
1019 + }
1020 + .workspace-layout:has(> .browser-panel) {
1021 + grid-template-columns: minmax(0, 1fr) 285px;
1022 + }
1023 + .workspace-layout > .browser-panel {
1024 + position: sticky;
1025 + top: 16px;
1026 + }
1027 + .dialog-actions {
1028 + flex-direction: row;
1029 + flex-wrap: wrap;
1030 + }
1031 + .dialog-actions .button {
1032 + flex: 1;
1033 + }
1034 +}
1035 +
1036 +@media (max-width: 420px) {
1037 + .topbar {
1038 + padding-inline: 15px;
1039 + min-height: 74px;
1040 + }
1041 + .app-main {
1042 + width: calc(100% - 28px);
1043 + padding-top: 25px;
1044 + }
1045 + .repo-card {
1046 + padding: 15px;
1047 + gap: 11px;
1048 + }
1049 + .repo-icon {
1050 + width: 36px;
1051 + height: 36px;
1052 + border-radius: 10px;
1053 + }
1054 + .repo-name {
1055 + font-size: 12px;
1056 + }
1057 + .editor-actions > .button.primary,
1058 + .sticky-actions > .button.primary {
1059 + flex: 1;
1060 + }
1061 + .editor-toolbar {
1062 + padding-inline: 10px;
1063 + }
1064 + .editor-status {
1065 + align-items: flex-start;
1066 + flex-direction: column;
1067 + }
1068 + .approval-panel {
1069 + padding: 20px;
1070 + }
1071 + .app-footer {
1072 + align-items: flex-start;
1073 + flex-direction: column;
1074 + }
1075 +}
1076 +
1077 +@media (prefers-reduced-motion: reduce) {
1078 + *,
1079 + *::before,
1080 + *::after {
1081 + animation-duration: 0.01ms !important;
1082 + transition-duration: 0.01ms !important;
1083 + }
1084 +}
web/src/types.ts new
+78
@@ -0,0 +1,78 @@
1 +export interface Limits {
2 + maxChars: number;
3 + maxBytes: number;
4 + maxFiles: number;
5 + maxAggregateBytes: number;
6 +}
7 +export interface Repository {
8 + id: string | number;
9 + name: string;
10 + fullName: string;
11 + defaultBranch: string;
12 + private: boolean;
13 + description: string | null;
14 +}
15 +export interface TreeItem {
16 + refId: string;
17 + name: string;
18 + path: string;
19 + type: string;
20 + size?: number;
21 +}
22 +export interface WorkspaceFile {
23 + path: string;
24 + draftText: string;
25 + revision: number;
26 +}
27 +export interface Workspace {
28 + id: string;
29 + repoId: string | number;
30 + repoFullName: string;
31 + baseBranch: string;
32 + baseHeadSha: string;
33 + state: string;
34 + path: string;
35 + files: WorkspaceFile[];
36 + commitMessage: string;
37 + result?: { commitSha?: string; branch?: string };
38 +}
39 +export interface WorkspaceResponse {
40 + workspace: Workspace;
41 + limits: Limits;
42 +}
43 +export interface Diff {
44 + text: string;
45 + additions: number;
46 + deletions: number;
47 + truncated: boolean;
48 +}
49 +export interface ReviewSnapshot {
50 + baseHeadSha: string;
51 + files: { path: string; revision: number }[];
52 +}
53 +export interface Approval {
54 + approvalRequested: boolean;
55 + workspaceId: string;
56 + targetBranch: string;
57 + baseHeadSha: string;
58 + expiresAt: number | string;
59 +}
60 +export interface TelegramWebApp {
61 + initData: string;
62 + ready?: () => void;
63 + expand?: () => void;
64 + enableClosingConfirmation?: () => void;
65 + disableClosingConfirmation?: () => void;
66 + close?: () => void;
67 + BackButton?: {
68 + show: () => void;
69 + hide: () => void;
70 + onClick: (callback: () => void) => void;
71 + offClick: (callback: () => void) => void;
72 + };
73 +}
74 +declare global {
75 + interface Window {
76 + Telegram?: { WebApp?: TelegramWebApp };
77 + }
78 +}
web/tsconfig.json new
+17
@@ -0,0 +1,17 @@
1 +{
2 + "compilerOptions": {
3 + "target": "ES2022",
4 + "lib": ["ES2022", "DOM", "DOM.Iterable"],
5 + "module": "ESNext",
6 + "moduleResolution": "Bundler",
7 + "allowImportingTsExtensions": true,
8 + "resolveJsonModule": true,
9 + "isolatedModules": true,
10 + "esModuleInterop": true,
11 + "jsx": "react-jsx",
12 + "strict": true,
13 + "noEmit": true,
14 + "skipLibCheck": true
15 + },
16 + "include": ["src"]
17 +}
web/vite.config.ts new
+33
@@ -0,0 +1,33 @@
1 +import { defineConfig } from 'vite';
2 +import { fileURLToPath } from 'node:url';
3 +
4 +export default defineConfig({
5 + root: fileURLToPath(new URL('.', import.meta.url)),
6 + base: '/studio/',
7 + build: {
8 + outDir: 'dist/studio',
9 + emptyOutDir: true,
10 + sourcemap: false,
11 + target: 'es2022',
12 + rollupOptions: {
13 + output: {
14 + manualChunks: {
15 + editor: [
16 + '@codemirror/state',
17 + '@codemirror/view',
18 + '@codemirror/commands',
19 + '@codemirror/language',
20 + '@codemirror/search',
21 + '@codemirror/lang-javascript',
22 + '@codemirror/lang-json',
23 + '@codemirror/lang-css',
24 + '@codemirror/lang-html'
25 + ]
26 + }
27 + }
28 + }
29 + },
30 + server: {
31 + host: '127.0.0.1'
32 + }
33 +});
wrangler.jsonc
+5
@@ -6,6 +6,11 @@
6 "workers_dev": true,
7 "keep_vars": true,
8 "observability": { "enabled": true },
9 + "assets": {
10 + "directory": "./web/dist",
11 + "binding": "ASSETS",
12 + "run_worker_first": true
13 + },
14 "durable_objects": {
15 "bindings": [
16 { "name": "APPROVAL_REPLAY_GUARD", "class_name": "ApprovalReplayGuard" },