Skip to content

feat(studio): X04a <forge-chat> embeddable chat widget element - #1120

Merged
LinuxDevil merged 4 commits into
mainfrom
fb-x04a-forge-chat
Nov 14, 2026
Merged

LinuxDevil merged 4 commits into
mainfrom
fb-x04a-forge-chat

Conversation

@LinuxDevil

Copy link
Copy Markdown
Owner

Summary

  • src/widget/sseFrames.ts — incremental SSE parser (chunk-safe, CRLF, comments, multi-line data, flush()).
  • src/widget/forgeChat.ts — <forge-chat> custom element: POSTs {sessionId, input} to the served agent's /chat SSE endpoint with optional bearer, streams text.delta, renders tool calls as one-line rows, maps the ticket's HTTP/network/error-frame/approval.requested copy, per-tab sessionStorage session id (storage-failure safe), Stop/Disconnect abort, role="log" + labelled textarea + reset aria-label.
  • src/widget/forgeChatStyles.ts — shadow-DOM stylesheet themed by --forge-chat-* properties with dark-scheme and reduced-motion handling. No app or @lousho/* imports; model text only ever via textContent.
  • X04b bundles and serves it.

Test plan

  • sseFrames.test.ts 8 tests — every-index chunking property test, CRLF, comments, multi-line data, flush
  • forgeChat.test.ts 18 tests — streaming render, bearer only when set, session persistence per tab/endpoint, storage-throw fallback, all error copies, Stop/disconnect abort, reset, Enter/Shift+Enter, a11y hooks, live attributes
  • typecheck, eslint clean, fallow clean on touched files (570 = baseline)

Stacked on #1117.

Generated with Devin

LinuxDevil and others added 3 commits November 13, 2026 03:53
/serve/<id>/* answers the SDK's whole chat API for the agent's pinned
published version: a Studio-global serve.json holds the per-agent
{enabled, token, allowedOrigins} switch, the Express<->Fetch bridge
streams raw bodies (mounted before express.json), and the SDK
createRouteHandler enforces the per-agent bearer + origin rules.
Handlers cache per published version and rebuild on a moved pointer;
rotating the token drops the cached handler so the old bearer dies.
Sessions persist under .lousho/agents/<id>/serve-sessions via a new
sessions slot on StudioRunDeps.

Management routes GET/PUT /agents/:id/serve, GET .../serve/token and
POST .../serve/rotate-token ride the studio-token /agents gate; /serve
itself is host-only at the global middleware and stays out of
API_PREFIXES, the SPA fallback and the Vite proxy.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
The X02a serve-surface wiring pushed createApp's cognitive complexity
to 17 (gate: 15). Store/service construction moves into
createStudioStores + createAuthorRunner; createApp is now a flat list of
register* calls. No behavior change.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Dependency-free custom element under src/widget/ (no app or @Lousho
imports): POSTs {sessionId, input} to the served agent's /chat SSE
endpoint, streams text deltas, renders tool calls as one-line rows,
maps HTTP/network/error-frame/approval copy per the ticket, keeps the
session id in sessionStorage per tab, and ships its own themed shadow-DOM
styles. X04b bundles and serves it.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@LinuxDevil
LinuxDevil changed the base branch from fb-x02a-serve-http to main November 14, 2026 13:21
# Conflicts:
#	apps/agent-forge/server/app.ts
#	apps/agent-forge/src/runtime/__tests__/runtimeClient.test.ts
@LinuxDevil
LinuxDevil merged commit dfaec8c into main Nov 14, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant