Documentation
¶
Overview ¶
Package server — the Idempotency-Key dedup middleware.
A retried mutation carrying a stable `Idempotency-Key` header replays the first response instead of re-executing. This is the app's ONLY idempotency layer, POST /api/command included; do not add a body-keyed dedup beside it.
Package server — the canonical-request-path gate over the API surface.
ServeMux answers a non-canonical path with a 307, which is SUCCESS to a non-following client (`curl -sf .../api/health` would read healthy unconsulted), so the API surface refuses a non-canonical spelling itself.
Package server — security middleware: CSP headers, the ALLOWED_HOSTS anti-DNS-rebinding gate, and stdlib CSRF protection (net/http.CrossOriginProtection).
Index ¶
- type AccountUsageProvider
- type KiroDoc
- type KiroDocsResponse
- type Option
- func WithAccountUsage(p AccountUsageProvider) Option
- func WithAgent(a chatEngine) Option
- func WithAuth(a routeHandler) Option
- func WithAuthUnavailable(unavailable func() bool) Option
- func WithChats(c routeHandler) Option
- func WithConfigDir(d string) Option
- func WithFiles(f routeHandler) Option
- func WithForges(r routeHandler) Option
- func WithGit(g routeHandler) Option
- func WithGovernanceLocks(g governanceLocks) Option
- func WithHostPolicy(p *webhttp.HostPolicy) Option
- func WithKASNode(path string) Option
- func WithKiroCLI(resolvePath func() string, resolveEnv func() []string) Option
- func WithKiroDefaults(k kiroDefaultsReader) Option
- func WithKiroReady(ready func() (bool, pinstall.Reason)) Option
- func WithKiroRescan(rescan func(context.Context) (bool, error)) Option
- func WithMCPConfig(r routeHandler) Option
- func WithMCPRegistry(r routeHandler) Option
- func WithMCPStatus(r routeHandler) Option
- func WithOnListen(fn func()) Option
- func WithPolicy(p policyProvider) Option
- func WithPolicyReload(p policyReloader) Option
- func WithPreview(r routeHandler) Option
- func WithPush(p routeHandler) Option
- func WithSensitive(sensitive filebrowse.Sensitive) Option
- func WithSpecApprovals(st *specapproval.Store) Option
- func WithStaticFS(staticFS fs.FS) Option
- func WithSteering(g SteeringGenerator) Option
- func WithTabs(st *tabs.Store) Option
- func WithTools(src toolsSource) Option
- func WithTrustedProxies(trusted []netip.Prefix) Option
- func WithWorkDir(d string) Option
- type Server
- type SteeringGenerator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AccountUsageProvider ¶
type AccountUsageProvider interface {
AccountUsage(ctx context.Context) (*marotte.AccountUsage, error)
}
AccountUsageProvider fetches account usage (plan, credits, quota) via KAS's _kiro/account/getUsage for GET /api/account/usage. Exported for server.WithAccountUsage.
type KiroDoc ¶
type KiroDoc struct {
Category string `json:"category"`
// Name is the row label: front-matter `name`, else the first H1, else the basename.
Name string `json:"name"`
Path string `json:"path"`
// Group is the parent label for a nested category: a spec's feature
// directory. Three files named requirements.md in a flat list identify
// nothing.
Group string `json:"group,omitempty"`
Description string `json:"description,omitempty"`
Inclusion string `json:"inclusion,omitempty"`
FileMatch string `json:"file_match,omitempty"`
Model string `json:"model,omitempty"`
// Trigger and Action carry a hook row (hooks are JSON, not markdown).
Trigger string `json:"trigger,omitempty"`
Action string `json:"action,omitempty"`
Tools []string `json:"tools,omitempty"`
SteeringOverride bool `json:"steering_override,omitempty"`
// ReadOnly says this row is not writable, so it renders without edit or delete. omitempty, so
// read-only is only ever asserted by the server, never produced by a field failing to arrive.
ReadOnly bool `json:"read_only,omitempty"`
// DeleteProtected says this row renders without DELETE but keeps its edit: set for an entry
// reached through a symlink, where the delete route would unlink the link's TARGET.
DeleteProtected bool `json:"delete_protected,omitempty"`
}
KiroDoc is one row on the configuration browser. Fields are per-category and mostly omitempty; the client shapes each tab's columns.
type KiroDocsResponse ¶
KiroDocsResponse is GET /api/workspace/kiro-docs's reply. Truncated says a cap or a cancelled request stopped the scan before it read the whole tree, so a short list is not read as the whole inventory.
type Option ¶
type Option func(*Server)
Option configures a Server at construction time.
func WithAccountUsage ¶
func WithAccountUsage(p AccountUsageProvider) Option
WithAccountUsage sets the provider backing GET /api/account/usage.
func WithAgent ¶
func WithAgent(a chatEngine) Option
WithAgent sets the agent runtime that owns the agent engine, its sessions and SSE broadcasts.
func WithAuth ¶
func WithAuth(a routeHandler) Option
WithAuth sets the auth handler for login, logout, and whoami endpoints.
func WithAuthUnavailable ¶
WithAuthUnavailable sets the sign-in leg /api/health reports. It must be a LATCH read, not a probe: the handler runs per request. Unset leaves readiness with no auth leg.
func WithChats ¶
func WithChats(c routeHandler) Option
WithChats sets the chat store, whose own router owns the chat HTTP surface.
func WithConfigDir ¶
WithConfigDir sets the configuration directory path used for chat files and settings.
func WithFiles ¶
func WithFiles(f routeHandler) Option
WithFiles sets the file handler for workspace file read/write endpoints.
func WithForges ¶
func WithForges(r routeHandler) Option
WithForges sets the route handler for forge (GitHub/GitLab/Gitea) HTTP endpoints.
func WithGit ¶
func WithGit(g routeHandler) Option
WithGit sets the git handler for the /api/git endpoints.
func WithGovernanceLocks ¶ added in v0.12.0
func WithGovernanceLocks(g governanceLocks) Option
WithGovernanceLocks sets the lock map a write to a locked kiro-cli setting is checked against.
func WithHostPolicy ¶
func WithHostPolicy(p *webhttp.HostPolicy) Option
WithHostPolicy sets the exact-match Host allowlist the security middleware applies before the CSRF check — the anti-DNS-rebinding gate. A nil or inactive policy accepts any Host.
func WithKASNode ¶ added in v0.13.0
WithKASNode sets the node binary KAS runs on, which compiles hook matchers exactly as KAS will. Unset, a hook with a matcher cannot be created.
func WithKiroCLI ¶
WithKiroCLI sets the resolvers for the kiro-cli binary and its environment: resolvers because the install manager selects (and can switch) the active version after the bind.
func WithKiroDefaults ¶ added in v0.13.0
func WithKiroDefaults(k kiroDefaultsReader) Option
WithKiroDefaults sets what GET /api/settings reports an unset three-state setting resolves to.
func WithKiroReady ¶
WithKiroReady sets the kiro-cli readiness verdict /api/health reports. Unset leaves the probe reflecting only that the listener is up.
func WithKiroRescan ¶
WithKiroRescan sets the disk-rescan hook the loopback repair route exposes. Unset leaves the route unmounted.
func WithMCPConfig ¶
func WithMCPConfig(r routeHandler) Option
WithMCPConfig sets the route handler for MCP server configuration endpoints.
func WithMCPRegistry ¶
func WithMCPRegistry(r routeHandler) Option
WithMCPRegistry sets the route handler for the MCP registry proxy endpoint.
func WithMCPStatus ¶
func WithMCPStatus(r routeHandler) Option
WithMCPStatus sets the route handler for the MCP runtime status endpoint.
func WithOnListen ¶
func WithOnListen(fn func()) Option
WithOnListen registers a callback fired once the listener has SUCCESSFULLY bound (a bind failure never fires it). It runs on the bind goroutine ahead of serving, so it must not block.
func WithPolicy ¶
func WithPolicy(p policyProvider) Option
WithPolicy sets the Cedar policy provider backing GET /api/permissions and POST /api/permissions/explain. The rule writer needs no provider.
func WithPolicyReload ¶
func WithPolicyReload(p policyReloader) Option
WithPolicyReload wires what a security-profile change needs after it persisted. Optional: unwired, live sessions keep the old presets and no client is told.
func WithPreview ¶ added in v0.10.12
func WithPreview(r routeHandler) Option
WithPreview sets the sandboxed web-preview routes.
func WithPush ¶
func WithPush(p routeHandler) Option
WithPush sets the push service used for Web Push notification delivery.
func WithSensitive ¶ added in v0.11.0
func WithSensitive(sensitive filebrowse.Sensitive) Option
WithSensitive sets the deny list the `.kiro` docs scan refuses, the same value the file browser holds.
func WithSpecApprovals ¶
func WithSpecApprovals(st *specapproval.Store) Option
WithSpecApprovals wires the spec-phase approval record the spec GET reads. A nil store stays a nil INTERFACE (not a typed nil), so the handler's unwired branch is taken.
func WithStaticFS ¶
WithStaticFS sets the embedded filesystem serving the compiled web UI.
func WithSteering ¶
func WithSteering(g SteeringGenerator) Option
WithSteering sets the steering generator used to produce environment.md for kiro-cli.
func WithTabs ¶
WithTabs wires the open-tab set GET /api/tabs reads. A nil store stays a nil INTERFACE (not a typed nil), so the handler's unwired branch is taken.
func WithTools ¶
func WithTools(src toolsSource) Option
WithTools sets the source of the tools engine backing the /api/tools surface.
func WithTrustedProxies ¶
WithTrustedProxies sets the reverse-proxy networks trusted when resolving the access-log client_ip. Empty trusts nothing, so the socket peer is logged.
func WithWorkDir ¶
WithWorkDir sets the workspace directory served by the file handler and git endpoints.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server holds shared state and registers all HTTP handlers.
func (*Server) ApplyGovernanceLocks ¶ added in v0.12.0
ApplyGovernanceLocks writes each locked kiro-cli setting to the administrator's value, so kiro-cli's own processes follow the lock, and writes the user's held value back to each setting whose lock lifted. Best-effort: a failure warns and the next lock change retries.
func (*Server) ListenAndServe ¶
ListenAndServe registers all routes and starts the HTTP server, blocking until SIGTERM/SIGINT.
func (*Server) SeedKiroSettings ¶ added in v0.12.9
SeedKiroSettings writes the Seed of each allowlisted kiro-cli setting that has one where kiro-cli holds no value, so a user's own choice survives a restart. A locked key is left to its lock, and a settings document kiro-cli cannot list seeds nothing. Call it once kiro-cli is installed.
type SteeringGenerator ¶
type SteeringGenerator interface {
CustomPath() string
}
SteeringGenerator generates steering files for kiro-cli. *steering.Generator satisfies it. Exported because the composition root names it in server.WithSteering.
Source Files
¶
- authready.go
- cli.go
- cli_handlers.go
- cli_seed.go
- compression.go
- deps.go
- etag.go
- fetchmeta.go
- idempotency.go
- kas_regexp.go
- kiro_docs.go
- kiro_docs_guard.go
- kiro_docs_new.go
- kirocli.go
- listen_linux.go
- pprof.go
- requestpath.go
- security.go
- server.go
- server_handlers_account.go
- server_handlers_policy.go
- server_handlers_policy_profile.go
- server_handlers_settings.go
- server_handlers_tabs.go
- server_static.go
- spec.go
- testhooks_stub.go
- tools_api.go
- tools_handlers.go