Serve an HTTP "web app" that lives entirely inside a Cline SDK agent's
conversation history. The agent is given a prompt describing the app
(e.g. "a TODO list with HTML pages and a JSON API at /api/todos"),
then deepserve opens a TCP port and pipes every raw HTTP request
into agent.continue(). The agent replies with a raw HTTP response,
which is written straight back to the socket.
This is a toy / demo — there is no context pruning, so long sessions will eventually overflow the model's context window.
Requires Node.js 22+ or Bun.
bun install
export CLINE_API_KEY="cline_..."# Inline prompt
bun run dev --port 8080 -- "A retro guestbook: GET / shows a form and \
the latest 10 entries; POST / accepts name and message form fields and \
appends an entry; entries are stored in your conversation memory."
# Or load the prompt from a file
bun run dev --port 8080 --prompt-file ./prompts/guestbook.txtThen in another shell:
curl -v http://127.0.0.1:8080/
curl -v -d 'name=Ada&message=Hello' http://127.0.0.1:8080/Each curl is one turn in the agent's conversation.
-p, --port <n> TCP port (default 8080)
--host <addr> Bind address (default 127.0.0.1)
-f, --prompt-file <p> Read the initial prompt from a file
--provider <id> SDK provider id (default "cline")
--model <id> Model id (default "anthropic/claude-sonnet-4.6")
Anything after -- (or any leftover positional args) becomes the
initial prompt.
- Construct an
Agentfrom@cline/sdkwith a minimal system prompt that says: first turn → acknowledge the spec in prose; every later turn → respond with raw HTTP/1.1 only. agent.run(initialPrompt)— the model "boots" the app.- A
net.createServeraccepts one HTTP request per connection (Content-Length framed), feeds the raw bytes toagent.continue(), and writes the agent'soutputTextback to the socket. - Requests are serialized so the conversation history stays linear.