feat(context): optional current-page awareness for embedded webchat
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 5/100
Línea de trabajo
Start with docs/http-contract.md and the request path in packages/dewee-webchat/src/widget/element.ts, src/widget/api-client.ts, src/server/handler.ts and src/server/gateway-client.ts to see how a chat turn is sent today. The issue is a multi-part design spanning the widget, both server implementations and the Gateway, so a newcomer should first ask a maintainer to split it into a smaller, agreed first step. Done means that step is agreed and its scope is written down in the issue.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Mục tiêu
Khi khách truy cập mở <dewee-chat> trên website đã bật tính năng, Dewee agent có thể hiểu nội dung trang hiện tại (bài viết, tài liệu, trang sản phẩm, mục hỗ trợ...) và trả lời câu hỏi như "trang này nói gì?" mà khách không phải dán URL hoặc copy nội dung.
Khác Chrome Extension: widget là script nhúng trên website, không có quyền đọc các tab/browser khác và không cần activeTab hay host permissions. Quyền truy cập context do site owner cấu hình + visitor kiểm soát; mặc định không tự động gửi nội dung trang tới backend/LLM.
Hiện trạng được kiểm tra (main @ 6f0083da8387)
packages/dewee-webchat/src/widget/element.tslà web component dùng Shadow DOM,DeweeChatConfigchưa có page-context setting;send(text)chỉ gọi API vớimessage/agent/conversationId.src/widget/api-client.tschỉ gửi các trường chat đó đếnPOST /api/dewee/chat;src/server/handler.tsforwardmessageđếnstreamChat;src/server/gateway-client.tsgọi Gateway WSchat.sendvớimessage/agentId/sessionKey/stream. Chưa có per-turn context attachment.docs/http-contract.mdlà hợp đồng dùng chung cho Node/Workers vàphp/dewee-webchat.php; phải cập nhật parity của cả hai server implementation + các framework wrappers/CDN/build docs. Không nhúng raw page vào user message bằng string concatenation.- Server giữ gateway token; visitor dùng signed session, origin allowlist và rate limits. Bảo toàn những biên an toàn này.
Thiết kế đề xuất
1. Host-controlled configuration + visitor UI
pageContext?: 'off' | 'metadata' | 'content', default 'off' để tránh vô tình chia sẻ dữ liệu của visitor khi upgrade SDK; site owner chủ động enable. Khicontentđược bật, widget chuẩn bị local ephemeral snapshot lúc mở, hiển thịCurrent page: title • preview • remove/disable; chỉ chuyển nội dung lên backend khi người dùng gửi tin nhắn và chọn chia sẻ ngữ cảnh theo chính sách consent rõ ràng.- Metadata mode gồm title/sanitized URL/description; content mode ưu tiên visible main content + selected text; nên hỗ trợ
contextSelector/excludeSelectors/contextProvider?: () => Promise<PageContext>tùy biến do site owner cung cấp. Không cho widget ăn toàn bộdocument.body.innerTextmột cách mù quáng. - SDK APIs/web component attributes hợp lý (đảm bảo SSR-safe):
page-context="content",configure({pageContext:'content'}); React/Vue/Astro wrappers truyền config; sự kiện privacy-awaredewee:context-ready,dewee:context-errorkhông chứa page text trong telemetry. - Không tự gọi LLM, không tự gửi nội dung trang khi widget chỉ load, không persist raw context vào localStorage/sessionStorage/history. Chat/persist session hiện tại giữ nguyên.
2. Shared versioned context envelope
Đồng bộ schema logic với issue Page Context trong nextlevelbuilder/dewee-chrome-ext:
{
"page_context": {
"version": 1,
"source": "embedded_webchat",
"url": "https://example.com/docs/article",
"title": "Article",
"captured_at": "2026-10-15T00:00:00Z",
"content": { "format": "markdown", "text": "# Article\n...", "truncated": false },
"trust_level": "untrusted_external"
}
}
- Client sanitize URL (strip credentials, fragments and secret-looking query keys); bound document size and use modest token budget (initial target 2k–4k, tune after eval).
- Server validates schema, enforces max size/length + visitor rate limits; assigns canonical source/trust server-side, not trusted from payload. Content is untrusted webpage text and must never become high-privilege instruction.
- Propagate attachment
widget → POST /api/dewee/chat → server handler (Workers/Node + PHP parity) → Dewee Gateway chat.send/agent looponly after backend support exists; do not silently fall back to interpolating raw context into user-authored message if feature not supported. - Per-turn context not injected into durable system prompt, public logs, traces, saved chat history, memory; preserve ownership and visitor isolation. Document backend dependency in
nextlevelbuilder/dewee.
3. Extraction, performance and security
- Extract only readable/visible content, headings, lists, code and tables with Readability-like filter; site-owner selectors override safely; never read form values, passwords, OTPs, payment fields, editable drafts, script/style/hidden DOM, cross-origin frames.
- Context keyed to current navigation/location/content hash; SPA route changes and updates invalidate snapshot; discard stale async results. No periodic background scraping; collect on open/explicit refresh + refresh on Send when stale.
- Host page can be malicious or contain prompt injection, so treat page as data only, not instructions. No origin bypass, token exfiltration or tool permission escalation.
- Inline use on site owner page, avoid cross-frame access; for iframe embedding, only expose explicitly approved context via a secure, exact-origin
postMessagehandshake if required later. Do not implement wildcard messaging or trust arbitraryevent.data. - No breaking change to existing
<dewee-chat>embeds. If disabled or context fails, normal chat still works. Keep browser bundle light and lazy-load extractor.
Implementation hotspots
packages/dewee-webchat/src/widget/element.ts(config + lifecycle + chip UI)packages/dewee-webchat/src/widget/api-client.tspackages/dewee-webchat/src/protocol.ts(shared type)packages/dewee-webchat/src/widget/page-context.ts(new extractor)packages/dewee-webchat/src/server/handler.ts&src/server/gateway-client.tsphp/dewee-webchat.php,docs/http-contract.md,packages/dewee-webchat/README.md- Examples and framework wrappers + tests.
Acceptance criteria
- Host enabling page-context allows question about actual current page without copying text; default existing embeds remain private and unchanged.
- Context status/chip preview/removal and visitor control work; no send until explicit chat submission + consent rule.
- Metadata/content/excluded selectors/custom provider behave consistently across HTML/React/Vue/Astro.
- Navigation/SPAs update context, no stale snapshot or cross-page bleed, selected text can be prioritized.
- No secrets, hidden data, form values, credentials, cookies, localStorage or cross-origin iframe content are captured.
- Node/Workers/PHP handlers all validate and propagate typed schema identically; Gateway receives untrusted per-turn context, not fake user/system instructions.
- Oversized/malformed content fails safely without breaking normal chat, no unbounded token costs, no page content persisted/logged.
- Unit/integration tests cover privacy, custom selectors, XSS/prompt injection, SPA, SSR import, parallel chats, history, visitor isolation, backend incompatibility and request limits.
Related
- Companion feature:
nextlevelbuilder/dewee-chrome-extPage Context Provider (link issue once published). - Backend contract/dependency:
nextlevelbuilder/deweetyped untrusted ephemeral context for chat runtimes. Share conceptual schema/parser semantics where practical, without force-coupling webchat widget code to Chrome APIs.
- Lenguaje dominante
- TypeScript
- Estrellas
- 7
- Forks
- 1
- Merge medio
- 1 d 6 h
- PR fusionados (30 d)
- 5
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de nextlevelbuilder/dewee-webchat
-
PHP backend: fixed file names in the shared temp dirPosiblemente ocupada @dannyward630 la tomó hace 1 día. Abiertoai-handle
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
-
ai-handle
Dificultad 3/5 1-2 días Aptitud para principiantes 38/100
-
ai-handle enhancement
Dificultad 4/5 3-5 días Aptitud para principiantes 38/100
-
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
-
ai-handle enhancement
Dificultad 5/5 Más de una semana Aptitud para principiantes 25/100
Todos los issues de nextlevelbuilder/dewee-webchat
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
components-web-app/docs#307 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
localstack/localstack-mcp-server#112 ·
Los mantenedores suelen responder en 1 día
-
area:frontend kind:bug priority:p1 ready
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
Los mantenedores suelen responder en 1 día
-
bug ready-for-agent
Dificultad 2/5 1-3 horas Aptitud para principiantes 73/100
PhyberApex/kuroshiro#1687 ·
Los mantenedores suelen responder en 1 día
-
Performance (Web Vitals) collector: LCP/FCP from background tabs are not discarded, inflating p75Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
umami-software/umami#4720 ·
Los mantenedores suelen responder en 3 días