Files
CST-agent/web/index.html
T
WHC 6e81513e36 v0.7.8: WebUI (--web): HTTP/1.1 + SSE front end, engine API v1, tests
A second implementation of cst_agent_hooks_t next to the TUI: the turn runs on
a worker thread, the hooks publish events into a ring buffer that SSE clients
read, so the engine itself needs no changes.

- src/net.c, include/cst_net.h: POSIX/Winsock sockets, non-blocking connect
- src/http_srv.c, include/cst_http.h: HTTP/1.1, keep-alive, chunked streaming,
  body caps (413), Expect: 100-continue, connection cap, exact routing
- src/web_md.c, include/cst_web_md.h: streaming markdown -> sanitized HTML
  (tag/attribute allowlist, javascript: URLs and off-site images dropped)
- src/webui.c, include/cst_webui.h: event ring + SSE broadcast, all routes,
  token (Bearer/Cookie/query) and loopback Host checks, 3 s auto-deny when no
  client is attached
- src/webui_stub.c, CST_WEBUI=0 / CST_BUILD_WEBUI=OFF: build without the WebUI
- web/: no-build front end (transcript, approvals, todo, sessions, image
  upload, status bar)
- docs/webui.md: engine API v1 - events, requests, security model
- tests/test_webui.c, scripts/e2e_webui.sh: unit tests plus an end-to-end run
  driven by a recorded SSE stream (no API key needed)
- src/main.c: --web --web-port --web-host --web-token --web-dev --web-open
  and CST_WEB_PORT/HOST/TOKEN/ROOT

An empty POST body is now accepted without Content-Length (RFC 9112 6.3) so
curl-driven clients can reach cancel/undo/compact/quit; CMakeList's core tests
learned about sashidown and test_webui, and CST_WEBUI=0 defines CST_NO_WEBUI.
2026-10-09 10:20:09 +08:00

42 lines
1.5 KiB
HTML

<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>CST-Agent</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<header id="bar">
<span class="tag" id="planmode">Build</span>
<span class="tag" id="approval">auto</span>
<span class="ws" id="ws" title="workspace"></span>
<span class="model" id="model" title="model">-</span>
<span class="muted" id="ctx"></span>
<span class="grow"></span>
<button id="btn-sessions" title="sessions">会话</button>
<button id="btn-model" title="model">模型</button>
<button id="btn-undo" title="undo">撤销</button>
<button id="btn-compact" title="compact">压缩</button>
<button id="btn-clear" title="clear view">清屏</button>
</header>
<main id="log"></main>
<aside id="todo" hidden></aside>
<footer id="composer">
<div id="pending" hidden></div>
<div class="row">
<textarea id="input" rows="1" placeholder="输入消息,Enter 发送,Shift+Enter 换行"></textarea>
<button id="btn-send">发送</button>
<button id="btn-stop" hidden>停止</button>
<label class="att" title="附上图片"><input type="file" id="file" accept="image/*" hidden>+图</label>
</div>
<div class="hint"><span id="status">就绪</span><span class="grow"></span><span id="usage" class="muted"></span></div>
</footer>
<div id="modal" hidden><div id="modal-box"></div></div>
<script src="app.js"></script>
</body>
</html>