Documentation
¶
Overview ¶
Package serve is the HTTP face of agentscope: it serves the wasm UI and the gRPC-over-WebSocket endpoint on one loopback origin.
What a page served here can reach is the whole point of the design, so it is narrow and stated:
- the listener is bound to a loopback address and refuses any other;
- every request, the WebSocket upgrade included, must carry a Host header naming the loopback address and port actually bound -- a DNS-rebinding page reaches this server with its own name in Host, and is answered 421;
- the WebSocket handshake additionally checks Origin against Host (the transport's same-origin default), so a page on another origin cannot open the stream even if it knew the port;
- the only methods are GET and HEAD, the only data is the read-only snapshot, and there is no endpoint that writes to the machine;
- responses carry a CSP that allows the page's own scripts and the wasm it instantiates, nothing from elsewhere.
Index ¶
Constants ¶
const GRPCPath = "/grpc"
GRPCPath is where the WebSocket carrying gRPC is mounted.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Addr string // host:port; the host must be a loopback IP; port 0 picks one
Web fs.FS // the UI: index.html, app.wasm, wasm_exec.js, ...
Scope wire.Scope
}
Config configures a Server.