Spaces:
Running
Running
Commit History
9 days ago
-
feat(chatbot-docgen): permanent in-chat document generation — PDF/DOCX/MD (v3.9.0)
ahmdelbaz28-uxOwner directive (2026-11-24): the bot must ALWAYS be able to build real files for the user inside the chat — no external skill loading, ever. - docgen skill 'docgen-file-export' in SKILL_REGISTRY (category export, thinking+instant): routed on file/export intent, emits a ```docgen DocSpec fence with the immediate-execution contract (file in the FIRST reply, verified numbers only, mandatory citations). - api/lib/docgen/: dependency-free deterministic renderers — PDF written from scratch (Type0/Identity-H CID fonts, two embedded GNU FreeFont subsets, full Arabic presentation-form shaping + simplified UAX#9 bidi with N0 bracket-pair + N1/N2 neutral resolution, RTL tables, page footers), DOCX as stored-ZIP OOXML (bidiVisual RTL tables, w:bidi paragraphs, Word-native shaping), and GFM Markdown. - POST /api/docs/gen: public, stateless, size-capped (60k content chars), typed 422 diagnostics — the /api/diagrams/sld contract. - Chat UI: renderDocgenFence download card (format …aea6c23
-
fix(sld): root-cause repairs — server-side spec repair + img-failure fallback + detector depth
Z UserRoot review of d37025f found two real holes, both closed at the source: 1) 422 → broken <img> in chat: the diagrams GET rendered nothing for a lint-failing spec (overlap, bad/duplicate ids), violating the router's own 'chat never breaks' contract at the last step, and the draw-now chip hid because a shape-valid fence was treated as delivered. Root fix: api/lib/sld/repair.ts — deterministic repair pass (sanitize ids, dedupe with first-occurrence wire mapping, drop dead wires, first-fit overlap relocation down/right/diag). Router GET/POST render the repaired spec; X-Sld-Repair header carries the audit trail; only a still-failing repair answers 422. renderSld/lintSpec untouched. 2) Residual broken-image icons: MessageBubble now attaches error listeners to SLD imgs and swaps failures for a localized note (createElement + textContent only — no model content). Detector depth: past-tense delivery claims (جهزت/حضرت/رسمت + المخطط), 'المخطط التالي/الآتي', EN 'the…e3276d9 -
feat(chat): SLD immediate-draw prompt rule + one-tap 'draw it now' chip
Z UserPrompt (v3.4.0): sldSkill AR/EN gain the IMMEDIATE EXECUTION RULE — sufficient data -> draw the spec board in the FIRST reply (promises, deferrals and permission-asking banned verbatim); one missing essential fact -> exactly ONE question; assumable -> assume + state one line. UI: detectUnfulfilledDiagramPromise() in chat-render.ts flags the last assistant reply when it promised/offered a diagram but carries no valid sld board (token-cap cut, broken fence, bare offer); ChatBot renders the 📐 ارسمها دلوقتي chip under it — one tap sends a language-mirrored follow-up that re-anchors the immediate-draw rule. Tests: 25 renderer cases (promise/offer/delivery vs teaching/imperative phrasing, board-invariance) + 6 quality contracts (happy/edge/failure matrix, thinking-only composition, changelog traceability). 478 total. Metrics snapshot: scripts/prompt-metrics/v3.4.0-sld-draw-now.json.d37025f -
fix(sld): zero-overlap label placement — labels sit BESIDE their element
Z UserVisual audit found labels painted on wires/symbols and colliding with the sheet title (G1 label vs title, 66/11kV across the breaker, Main 11kV cut by its feed wire). - placeLabels(): every label is scored against title/bodies/labels/wires/ sheet edges; first zero-collision spot wins (right > left > below > above; busbars prefer left). Deterministic least-collision fallback. - Busbar fan-out dots stagger LEFTWARD so connection dots stay ON the bar. - sheetSize() reserves a side band (96px) when labels exist; geometry shifts half-band right so left-side labels never clip. - Over-long titles squeeze via textLength instead of spilling over row 0. - chat-render: append &v=3 to SLD URLs to bust stale immutable caches. - New regression suite parses the rendered SVG and asserts every label is clear of wires, symbols, other labels and the title (dark/light/dense).37435b7 -
feat(sld): draw single-line diagrams — spec-in, SVG-out, model text never becomes markup
Z UserPhase 1 of the electrical-diagram capability, architecture ported from abduznik/electrical-schematics-skill (grid layout, orthogonal routing, generate→audit→fix discipline) onto our Node runtime: - api/lib/sld/: types (grid→px placement, terminals), symbols (12 ETAP power elements, dark/light themes), lint (bounds/overlap/refs/grid), render (deterministic SVG, monotonic 3-segment routing with per-source fan-out columns, gap-clamped turns) - api/diagrams-router.ts: GET image/svg+xml (lint-fail = 422 + findings, immutable cache), POST JSON (svg + findings + canonical url) — public, read-only, zero storage, spec capped at 4k chars/40 elements - chat: sldSkill (Ar+En) injected THINKING-mode only — instant untouched; the model emits a sld JSON fence, never pixels; chat-render synthesizes the ONLY allowed img: same-origin /api/diagrams/... whose SVG comes exclusively from our linted renderer — malformed fences fall back to the escaped code block (streaming-safe) - tests: 1…ccfdb3c
-
fix(security): remediate audit run-1 confirmed findings (20)
Z UserCloudflare security-audit skill, full audit of 8ea551b (quick profile, source-only): 34 coverage units, 8 hunter domains, 6 independent verifiers, 21 confirmed + 7 needs_validation records. Artifacts: security-audit-skill/elbaz-platform/run-1/{REPORT,FINDINGS-DETAIL, NEEDS-VALIDATION}.md + findings.json (schema-validated) + coverage-ledger.json. HIGH (both XSS): - chat renderer: extract pure renderer to src/lib/chat-render.ts and escape EVERY text segment before markdown transformation (was: code fences only); href attribute breakout closed; biome-ignore safety claims made true; regression tests (img/script/href-breakout/table-cell payloads) - seo-meta: jsonLdSafeStringify escapes < > U+2028/2029 so stored course titles/FAQ questions cannot break out of the JSON-LD <script> element (the nonce stamper previously re-armed the injected script); tests MEDIUM: - CSRF: same-origin gate in security middleware for POST/PUT/PATCH (Origin/ Referer must match the CORS allowlist when…e5934c3