web/

directory
v0.0.0-...-7c75ef6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 27, 2026 License: Apache-2.0

README

pkg/web

Everything served over HTTP (plus the one gRPC service that shares the group's "a client reaches us over the wire" concern).

The boundary rule: a package belongs here when its job is serving a request to a client outside the process — routing, page assembly, authorization of an HTTP request, response encoding, browser asset delivery. Domain logic behind that surface belongs to the group that owns the domain: sessions to pkg/agent, transports to pkg/channels, memory and audit to pkg/memory, identity to pkg/platform. A handler here should read as authorize, delegate, encode.

web/ and pkg/web/ are different things

There is a root-level web/ directory. It is not this.

What it is
web/ (repo root) The TypeScript side. A pnpm + Vite workspace: shared packages (packages/agentui, packages/design, packages/runtime), the Tailwind/Vite/Vitest config, and the build that produces the browser bundles. Carries its own go.mod sentinel so Go tooling's ./... walks skip it.
pkg/web/ (here) The Go side. The servers, handlers, authorization gates, and page assembly that deliver those bundles and answer their API calls.

They meet at exactly one place: Vite writes its output into webui/webassets/dist/, which webui/webassets //go:embeds. See that package's README — dist/ is committed build output and must never be hand-edited.

Per-feature TypeScript is colocated with the Go handler that serves it, in a ui/ directory (webui/chat/ui/, adminui/ui/, …). An app.json in a ui/ directory declares a bundle entry point; a ui/ directory without one is a component library imported by some other entry.

Who serves what

Binary Uses
internal/cmd/webd webui and its plugins, adminui, browsersession, uibindings
internal/cmd/operator admind, gateway, secretoutsrv
internal/cmd/runner uiview, uigrant — the agent side of agent-defined UI
cmd/oap localtunnel, viewurn

The admin console is split across two binaries on purpose: adminui (webd) serves the console's HTML and JS and reverse-proxies /admin/api/<rest> → <admind>/admin/v1/<rest>; admind (operator) is the API and holds the authorization gate. The browser never talks to admind directly.

Subpackages

Package What it holds
admind The admin console backend API, mounted by the operator: live sessions, audit, config, cost, cluster health, kill. SpiceDB-gated.
adminui The admin console frontend — React shell under ui/, login, and the reverse proxy to admind.
browsersession The single writer for the cluster objects a browser-channel AgentSession is made of: ephemeral Channel, owner-ref'd credentials Secret, the AgentSession, and the SpiceDB started_by relation. Readers it does not own (channelsd correlation, the operator's owner resolver, the chat registry) depend on that shape.
gateway A bidirectional gRPC byte-pump into a live process in a session's sandbox pod. Not the Kubernetes Gateway API and not grpc-gateway — see its README.
localtunnel Exposes an in-cluster port as a public HTTPS URL for a cluster with no ingress, so OAuth redirect_uris and webhook URLs resolve. Tunnel interface + provider registry, driven by PublicEndpoint; ngrok implemented, stub for tests.
secretoutsrv The operator endpoint a runner POSTs a captured secret-output value to. The operator, not the runner, writes the Secret — the runner has no Secret-write RBAC.
uibindings Resolves an agent-UI binding source to a value. Registry of source kinds: actionstate, artifactref, memoryref, tool.
uicomponents The agent-UI component vocabulary: component schemas, declaration shape, prop/binding validation, and the view model handed to the browser.
uidemo A worked agent-UI demo (leadflow) used to exercise the stack end to end.
uiselect The binding selector language — a deliberately tiny, total, non-executing path expression (results[].properties) that says which part of a source value fills a prop. No filters, wildcards, indices, or recursion.
uiview Merges an AgentUI CR plus the agent's stored fragments into the one declaration everything downstream reads: browser bootstrap, binding lookup, action lookup, live push, and the runner's write-time validation.
uigrant Computes, fail-closed, which tools an agent-defined UI may invoke directly from a browser — the intersection of what the bundle requested, what the tool's origin permits, and what the deployment granted. Three separate objects written by three separate people.
viewurn The view-URN grammar (urn:ap:view:<type>:<nss>) naming the surface an inbound came from. One Parse/Format pair in the codebase — a drifted URN is both a Slack markup-injection and an LLM prompt-injection surface, because a Via string is rendered into a Slack message and into the agent's context.
webui The browser server: transcript/chat, agent-UI pages, artifact viewing, the session shell, and the embedded assets.

Things to know before adding a handler

  • Authorize every request at the handler. The browser surfaces (webui/chat, webui/agentui, webui/sessions) each check agentsession#interact on every request; nothing here relies on an ambient or upstream check.
  • Authentication is never ambient. Handlers mounted onto a shared mux authenticate their own requests — the mux adds nothing. That is true of the operator's mux (pkg/x/debug) in particular.
  • Untrusted content is isolated, not trusted. Anything agent- or user-authored that reaches a browser goes through the artifact host's origin/CSP isolation rather than being rendered into a first-party page. See webui/artifactview.
  • dist/ is generated. Never hand-edit it; mage web:check fails on drift.

Directories

Path Synopsis
Package admind is the operator-mounted admin API: live session aggregation (CRD watch + NATS overlay), cross-session audit queries, and session kill.
Package admind is the operator-mounted admin API: live session aggregation (CRD watch + NATS overlay), cross-session audit queries, and session kill.
agentcred
Package agentcred is the wire contract for replacing an agent's OWN shared credential, plus the client half of it.
Package agentcred is the wire contract for replacing an agent's OWN shared credential, plus the client half of it.
audit
Package audit normalizes memory entries from the audit-producing Kinds into one cross-session Event shape, via a per-memory-kind Mapper registry (repo convention: new variants register, consumers don't branch).
Package audit normalizes memory entries from the audit-producing Kinds into one cross-session Event shape, via a per-memory-kind Mapper registry (repo convention: new variants register, consumers don't branch).
config
Package config is the resource-projector layer behind the admin UI's Config phase.
Package config is the resource-projector layer behind the admin UI's Config phase.
config/projectors
Package projectors holds the per-CRD config.Projector implementations that sit behind the admin UI's Config phase.
Package projectors holds the per-CRD config.Projector implementations that sit behind the admin UI's Config phase.
cost
Package cost provides a per-model token price map and cost estimator for the admin dashboard.
Package cost provides a per-model token price map and cost estimator for the admin dashboard.
health
Package health computes the admin Overview's cluster-health snapshot: the live up/down state of each first-party platform component plus a namespace pod/replica rollup.
Package health computes the admin Overview's cluster-health snapshot: the live up/down state of each first-party platform component plus a namespace pod/replica rollup.
overview
Package overview computes the admin dashboard's Overview payload: token rollups by model and by AgentClass, a 24-hour hourly token time-series, and the top-line KPI scalars.
Package overview computes the admin dashboard's Overview payload: token rollups by model and by AgentClass, a 24-hour hourly token time-series, and the top-line KPI scalars.
Package adminui is the webd plugin for the platform admin UI: the /admin React page plus /admin/api/* reverse-proxy routes to the operator-mounted admind API.
Package adminui is the webd plugin for the platform admin UI: the /admin React page plus /admin/api/* reverse-proxy routes to the operator-mounted admind API.
Package browsersession creates the cluster objects a browser-channel AgentSession is made of: the ephemeral Channel, its owner-ref'd credentials Secret, and the AgentSession itself, plus the SpiceDB started_by relation that gives the session a resolvable owner.
Package browsersession creates the cluster objects a browser-channel AgentSession is made of: the ephemeral Channel, its owner-ref'd credentials Secret, and the AgentSession itself, plus the SpiceDB started_by relation that gives the session a resolvable owner.
Package gateway provides the streaming gRPC service that connects clients to active ToolCall exec streams in the operator.
Package gateway provides the streaming gRPC service that connects clients to active ToolCall exec streams in the operator.
v1
Package goals serves authenticated goal management on the operator data plane.
Package goals serves authenticated goal management on the operator data plane.
Package localtunnel exposes a local TCP port as a public HTTPS URL for development workflows.
Package localtunnel exposes a local TCP port as a public HTTPS URL for development workflows.
ngrok
Package ngrok provides a Tunnel implementation backed by ngrok's Go agent SDK (golang.ngrok.com/ngrok/v2).
Package ngrok provides a Tunnel implementation backed by ngrok's Go agent SDK (golang.ngrok.com/ngrok/v2).
registry
Package registry is the process-wide tunnel-provider registry: it maps a PublicEndpointSpec.Provider name (e.g.
Package registry is the process-wide tunnel-provider registry: it maps a PublicEndpointSpec.Provider name (e.g.
stub
Package stub provides a deterministic Tunnel implementation for tests.
Package stub provides a deterministic Tunnel implementation for tests.
Package mcpfront is the externally-reachable MCP surface: the OAuth minter, the /mcp bearer middleware, and the typed ops layer.
Package mcpfront is the externally-reachable MCP surface: the OAuth minter, the /mcp bearer middleware, and the typed ops layer.
Package secretoutsrv exposes an authenticated operator HTTP endpoint that a runner POSTs a captured secret-output value to; the operator (NOT the runner) writes it into the per-session secret-output Secret.
Package secretoutsrv exposes an authenticated operator HTTP endpoint that a runner POSTs a captured secret-output value to; the operator (NOT the runner) writes it into the per-session secret-output Secret.
Package sessionevents serves trusted component event ingress.
Package sessionevents serves trusted component event ingress.
Package settingseditor is the server-agnostic core of the settings editor UI: validation aggregation over the admission-webhook checks plus the pure settings resolver, YAML round-trip for the raw editor, and SSA drift reporting.
Package settingseditor is the server-agnostic core of the settings editor UI: validation aggregation over the admission-webhook checks plus the pure settings resolver, YAML round-trip for the raw editor, and SSA drift reporting.
Package uibindings is the data-binding resolver contract: the seam a declared component prop's binding (pkg/web/uicomponents.Binding) crosses to become a value, resolved SERVER-SIDE under the viewer's subject.
Package uibindings is the data-binding resolver contract: the seam a declared component prop's binding (pkg/web/uicomponents.Binding) crosses to become a value, resolved SERVER-SIDE under the viewer's subject.
actionstate
Package actionstate is the "action" uibindings.Resolver: it answers "what is this declared action doing right now, for THIS viewer" out of the ui_action memory records the runner writes.
Package actionstate is the "action" uibindings.Resolver: it answers "what is this declared action doing right now, for THIS viewer" out of the ui_action memory records the runner writes.
artifactref
Package artifactref is the "artifact" uibindings.Resolver: a read-only resolution of an artifact handle to its rendered bytes, scoped to the viewer's own session exactly the way the artifact-view page's own deps already resolve handles (internal/cmd/webd's artifactViewDeps.ResolveAssetURL) — a handle belonging to a different session simply isn't found within this scope, which is what makes it unresolvable rather than merely unauthorized.
Package artifactref is the "artifact" uibindings.Resolver: a read-only resolution of an artifact handle to its rendered bytes, scoped to the viewer's own session exactly the way the artifact-view page's own deps already resolve handles (internal/cmd/webd's artifactViewDeps.ResolveAssetURL) — a handle belonging to a different session simply isn't found within this scope, which is what makes it unresolvable rather than merely unauthorized.
memoryref
Package memoryref is the "memory" uibindings.Resolver: a read-only memory.Query scoped to the viewer's own session.
Package memoryref is the "memory" uibindings.Resolver: a read-only memory.Query scoped to the viewer's own session.
registry
Package registry is the process-wide binding-source resolver registry.
Package registry is the process-wide binding-source resolver registry.
tool
Package tool is the "tool" uibindings.Resolver: it turns one agent-UI data binding into the same synchronous, readonly-gated app-tool call the runner already answers for MCP-UI widgets.
Package tool is the "tool" uibindings.Resolver: it turns one agent-UI data binding into the same synchronous, readonly-gated app-tool call the runner already answers for MCP-UI widgets.
Package uicomponents is the agent-UI component vocabulary: the closed set of renderable types an AgentUI declaration (author-written) or a view-model (agent-written) may name.
Package uicomponents is the agent-UI component vocabulary: the closed set of renderable types an AgentUI declaration (author-written) or a view-model (agent-written) may name.
component
Package component holds the Component type in a package that does NOT depend on pkg/web/uicomponents.
Package component holds the Component type in a package that does NOT depend on pkg/web/uicomponents.
registry
Package registry is the process-wide agent-UI component registry.
Package registry is the process-wide agent-UI component registry.
uidemo
leadflow
Package leadflow is a fabricated CRM MCP server used to demonstrate the agent-defined-UI leads console.
Package leadflow is a fabricated CRM MCP server used to demonstrate the agent-defined-UI leads console.
Package uigrant computes which tools an agent-defined UI may invoke directly from a browser.
Package uigrant computes which tools an agent-defined UI may invoke directly from a browser.
Package uiselect is the agent-UI binding selector language: the total, non-executing path expression a uicomponents.Binding uses to say WHICH part of a resolved source value fills a component prop.
Package uiselect is the agent-UI binding selector language: the total, non-executing path expression a uicomponents.Binding uses to say WHICH part of a resolved source value fills a component prop.
Package uiview turns an AgentUI CR plus the agent's stored Tier-1 fragments into the one merged declaration everything downstream reads: the browser bootstrap, a binding-path lookup, an action-name lookup, the live push, and the runner's own write-time validation.
Package uiview turns an AgentUI CR plus the agent's stored Tier-1 fragments into the one merged declaration everything downstream reads: the browser bootstrap, a binding-path lookup, an action-name lookup, the live push, and the runner's own write-time validation.
Package viewurn owns the view-URN grammar: the stable string that names the browser/TUI surface a session-view inbound came from.
Package viewurn owns the view-URN grammar: the stable string that names the browser/TUI surface a session-view inbound came from.
Package webui is the framework for webd's browser UIs: a registry of scoped, two-origin WebUI plug-ins served by one host binary.
Package webui is the framework for webd's browser UIs: a registry of scoped, two-origin WebUI plug-ins served by one host binary.
agentui
actions.go serves POST /agent-ui/{ns}/{name}/actions: the browser's only way to INVOKE a declared agent-UI action — the WRITE half of the binding vocabulary, where data bindings (bindings.go) are read-only by construction.
actions.go serves POST /agent-ui/{ns}/{name}/actions: the browser's only way to INVOKE a declared agent-UI action — the WRITE half of the binding vocabulary, where data bindings (bindings.go) are read-only by construction.
browserstart
Package browserstart is the ONE reserve -> create -> adopt sequence behind every browser-facing start route.
Package browserstart is the ONE reserve -> create -> adopt sequence behind every browser-facing start route.
channelwebhook
Package channelwebhook mounts ONE route that accepts inbound HTTP deliveries for ANY channel kind implementing channelkinds.WebhookReceiver (see pkg/channels/channelkinds/webhook.go).
Package channelwebhook mounts ONE route that accepts inbound HTTP deliveries for ANY channel kind implementing channelkinds.WebhookReceiver (see pkg/channels/channelkinds/webhook.go).
chat
Package chat is the transcript view's data plane: a webui.WebUI plugin serving the session-scoped read/write/websocket routes a conversation needs.
Package chat is the transcript view's data plane: a webui.WebUI plugin serving the session-scoped read/write/websocket routes a conversation needs.
chatembed
Package chatembed serves the ONE-session browser chat as an embeddable page: GET /chat-embed/{ns}/{name} mounts the transcript data plane's chat view and the shell's startup line for that session, with no tabs, no header and no session list, so another same-origin page (the agent-builder's Test panel, through ap:chat) can frame it.
Package chatembed serves the ONE-session browser chat as an embeddable page: GET /chat-embed/{ns}/{name} mounts the transcript data plane's chat view and the shell's startup line for that session, with no tabs, no header and no session list, so another same-origin page (the agent-builder's Test panel, through ap:chat) can frame it.
contenttoken
Package contenttoken mints + verifies short-lived HMAC capability tokens that gate webd's sandbox-origin artifact endpoints: /content (the primary artifact framed by the live-view), /artifacts/a/ (a same-session secondary artifact referenced from the primary via `artifact:HANDLE`), and /mcpui-content + /mcpui-host (an MCP-UI interactive widget framed by the session-view page).
Package contenttoken mints + verifies short-lived HMAC capability tokens that gate webd's sandbox-origin artifact endpoints: /content (the primary artifact framed by the live-view), /artifacts/a/ (a same-session secondary artifact referenced from the primary via `artifact:HANDLE`), and /mcpui-content + /mcpui-host (an MCP-UI interactive widget framed by the session-view page).
cspassets
Package cspassets assembles the nonce-authorized <style>/<script> tags a page needs and derives the matching Content-Security-Policy from them.
Package cspassets assembles the nonce-authorized <style>/<script> tags a page needs and derives the matching Content-Security-Policy from them.
health
Package health is a trivial built-in WebUI: a public GET /healthz on the trusted origin.
Package health is a trivial built-in WebUI: a public GET /healthz on the trusted origin.
interact
Package interact is the webui.WebUI plugin serving the browser's authorized path to act on a session it can view: POST /session/{ns}/{name}/interact dispatches a decoded interaction kind (pkg/channels/interact) through layered, fail-closed gates, and GET /session/{ns}/{name}/interactions reports which kinds this class permits (gate order in handlers.go).
Package interact is the webui.WebUI plugin serving the browser's authorized path to act on a session it can view: POST /session/{ns}/{name}/interact dispatches a decoded interaction kind (pkg/channels/interact) through layered, fail-closed gates, and GET /session/{ns}/{name}/interactions reports which kinds this class permits (gate order in handlers.go).
internal/wstest
Package wstest scales the websocket read deadlines the pkg/web/webui tests set on a connection, so a loaded or instrumented box lengthens them instead of failing them.
Package wstest scales the websocket read deadlines the pkg/web/webui tests set on a connection, so a loaded or instrumented box lengthens them instead of failing them.
livemirror
Package livemirror holds the shared, session-agnostic logic for replaying a session's durable memory turns into the ordered timeline a live view renders — the piece every mirror of a live conversation (the built-in web chat, the read-only session-view page) needs identically.
Package livemirror holds the shared, session-agnostic logic for replaying a session's durable memory turns into the ordered timeline a live view renders — the piece every mirror of a live conversation (the built-in web chat, the read-only session-view page) needs identically.
registry
Package registry holds the global WebUI registry.
Package registry holds the global WebUI registry.
sessions
pkg/web/webui/sessions/list.go joins the sessions a subject may interact with (SpiceDB's answer, via LookupInteractableSessions) against their Kubernetes objects (class, phase, title, start time) to build the sidebar list GET /sessions and GET /sessions/api/sessions both render.
pkg/web/webui/sessions/list.go joins the sessions a subject may interact with (SpiceDB's answer, via LookupInteractableSessions) against their Kubernetes objects (class, phase, title, start time) to build the sidebar list GET /sessions and GET /sessions/api/sessions both render.
sessionview
Package sessionview is the webui.WebUI plugin serving a SESSION-scoped (not artifact-scoped) shared live view: a read-only mirror of a session's conversation for a subject who can interact with it but was not the session's originating channel.
Package sessionview is the webui.WebUI plugin serving a SESSION-scoped (not artifact-scoped) shared live view: a read-only mirror of a session's conversation for a subject who can interact with it but was not the session's originating channel.
webassets
Package webassets embeds the built web UI bundles (pkg/web/webui/webassets/dist, produced by Vite under web/) and exposes the asset filesystem + parsed manifest.
Package webassets embeds the built web UI bundles (pkg/web/webui/webassets/dist, produced by Vite under web/) and exposes the asset filesystem + parsed manifest.
Package workshopdraftsrv exposes the ONE operator route the agent-builder workshop sidecar's export_draft tool (plan 3b, Task 7) posts a drafted .oap bundle to:
Package workshopdraftsrv exposes the ONE operator route the agent-builder workshop sidecar's export_draft tool (plan 3b, Task 7) posts a drafted .oap bundle to:
Package workshopprojectsrv exposes the ONE operator route that lets an agent-builder workshop's builder session project a CREDENTIAL-FREE STAND-IN for another agent it may want to hand work to during REHEARSAL (agent-builder plan 9b, Task 1):
Package workshopprojectsrv exposes the ONE operator route that lets an agent-builder workshop's builder session project a CREDENTIAL-FREE STAND-IN for another agent it may want to hand work to during REHEARSAL (agent-builder plan 9b, Task 1):
Package workshopthreadsrv exposes the ONE operator route that lets an agent-builder workshop's builder session learn who else has already worked the conversation thread it was just pulled into (plan 9a, Task 1):
Package workshopthreadsrv exposes the ONE operator route that lets an agent-builder workshop's builder session learn who else has already worked the conversation thread it was just pulled into (plan 9a, Task 1):
Package workshoptranscriptsrv exposes the ONE operator route that lets an agent-builder workshop's builder session read back the transcript of a session run inside that workshop's own namespace to test what the builder built:
Package workshoptranscriptsrv exposes the ONE operator route that lets an agent-builder workshop's builder session read back the transcript of a session run inside that workshop's own namespace to test what the builder built:

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL