Documentation
¶
Overview ¶
Package chat installs the in-app Kiln chat panel. The panel is a small vanilla-JS UI mounted under /kiln/* on Live's auxiliary router so it survives world rebuilds. It speaks to the host via:
GET /kiln/chat the panel HTML
GET /kiln/chat/panel.js the panel runtime
GET /kiln/chat/panel.css the panel stylesheet
GET /kiln/world current Session as JSON
POST /kiln/chat/message shortcut for tools.Chat
POST /kiln/tool/{name} generic tool dispatch
GET /.kiln/events live SSE stream of session events
The panel itself does not need world IR coverage — it's the host's own surface, not something the agent edits. Kiln-built apps still drive the panel by issuing tool calls; the panel is just the eyes.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HostHTML ¶
func HostHTML() string
HostHTML is the empty-state shell. Returned to any unmatched HTML request so the floating widget is always reachable. The embedded HTML uses placeholders we substitute at serve time:
__KILN_BASE__ the server's scheme+host (per-request when possible) __KILN_LEAD__ the welcome paragraph (adapts to current world) the runtime <script> tag (hashed for cache-busting)
HostHTML hard-codes localhost:8765 + the empty-world lead so non- request callers (chat tests, snapshots) still produce a complete page. For live serving with a Live runtime, prefer HostHTMLForLive.
func HostHTMLForLive ¶
HostHTMLForLive is HostHTMLForRequest with the lead paragraph computed from the Live runtime's current world: empty world → the default copy; non-empty → a per-noun summary so visitors see what the agent has built without opening the panel.
func HostHTMLForRequest ¶
HostHTMLForRequest is HostHTML with __KILN_BASE__ substituted from the actual incoming request's scheme + host. Lead text stays the empty-world message — for world-aware lead use HostHTMLForLive.
func MountPanel ¶
MountPanel registers the kiln chat panel as a core-ui/widget on r. The widget is a framework-managed FloatingPanel; kiln contributes:
- slot HTML for header / log / input (rendered server-side from session)
- a 2s /state poll that keeps the chat_html/agent/world signals fresh
- RPC handlers for chat send, reset, approve/reject, agent control
agentState is read by the gear modal's agent_list_html signal at mount time so the user sees the actual adapter list (claude-code, omp, claude-code, pi, codex, ...) instead of a Loading… placeholder. nil → no list.
All bespoke kiln widget plumbing (vanilla JS DOM, hand-rolled CSS, per-route HTTP handlers) is replaced by this single declaration.
Types ¶
type AgentStateFn ¶
type AgentStateFn func() any
AgentStateFn returns the JSON-shaped agent state consumed by the gear modal. Shape: { current: {name, display}, available: [{name, display, installed}, ...], in_flight: bool }. Concretely supplied by cmd/kiln (which owns the AdapterStore); kept as a callback so the chat package doesn't depend on cmd/kiln. Pass nil to render an empty modal (development / tests without an adapter registry).