localfileapi

package
v0.36.0 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddRoutes

func AddRoutes(mux *http.ServeMux, service localfileservice.Service)

func AddWorkspaceRoutes added in v0.36.0

func AddWorkspaceRoutes(mux *http.ServeMux, factory *vfs.Factory, hitlFor PolicyEvaluatorFactory) error

AddWorkspaceRoutes registers the /files browse API in per-root mode: every request names its workspace via the `root` query parameter (or the request body's `root` field for writes), which is validated against the allowlist before a rooted localfileservice serves it. The empty value and "/" resolve to the default root, matching the session cwd compat rule. Requests for a non-allowlisted root are rejected — a browser can browse any allowlisted root but nothing outside the allowlist.

hitlFor, when non-nil, enables the `agent` view filter on GET /files: it builds a HITL service bound to the requested (or default) policy so per-entry access verdicts are computed by the agent's real policy engine. When nil, requesting filter=agent returns an unprocessable-entity error (the filter is not available on that deployment) while the unfiltered tree is unchanged.

Types

type Entry added in v0.36.0

type Entry struct {
	localfileservice.Entry
	// Access is the agent-view verdict for this path; present only under the
	// `agent` filter.
	Access *agentview.Verdict `json:"access,omitempty"`
}

Entry is a /files list element: the raw filesystem entry plus optional, filter-contributed annotations. localfileservice.Entry is embedded (anonymous, untagged) so its fields promote to the top level and the base JSON shape stays byte-identical to the unfiltered response; a filter only ever ADDS fields such as `access`, which stay absent (omitempty) when no filter runs.

type FileFilter added in v0.36.0

type FileFilter interface {
	Name() string
	Apply(ctx context.Context, entries []Entry, ev *agentview.Evaluator) ([]Entry, error)
}

FileFilter transforms a listing into an annotated and/or narrowed listing. The `filter` query param on GET /files selects one by Name(). Filters are the extension point for future views (gitignore, filetype, modified-since): each registers as a named implementation and may add its own optional Entry fields. The evaluator is supplied so a filter that needs per-path agent verdicts can compute them without reimplementing the agent's gates.

type PolicyEvaluatorFactory added in v0.36.0

type PolicyEvaluatorFactory func(policyName string) hitlservice.Service

PolicyEvaluatorFactory builds a HITL service bound to a specific policy name. An empty policyName selects the runtime's default policy resolution (the same resolution the live agent uses). Non-empty forces that exact named policy.

Jump to

Keyboard shortcuts

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