Documentation
¶
Overview ¶
Package sitetool is the manage_site MCP tool (#2518): a site's record, its environments, publishing a release, promoting and rolling back, mapping hostnames and the migration crawl, over the one service.
Index ¶
Constants ¶
const ( CmdCreate = "create" CmdGet = "get" CmdList = "list" CmdUpdate = "update" CmdDelete = "delete" CmdEnvironment = "set_environment" CmdPublish = "publish" CmdPromote = "promote" CmdRollback = "rollback" CmdReleases = "releases" CmdDeployments = "deployments" CmdAddDomain = "add_domain" CmdRemoveDomain = "remove_domain" CmdDomains = "domains" CmdCrawl = "crawl" CmdGrant = "grant" CmdRevoke = "revoke" CmdSetDomain = "set_domain" // CmdRemoveEnvironment removes an environment between dev and prod // (#2630). CmdRemoveEnvironment = "remove_environment" )
The commands.
const ToolName = "manage_site"
ToolName is the tool's name.
Variables ¶
var Commands = []string{ CmdCreate, CmdGet, CmdList, CmdUpdate, CmdDelete, CmdEnvironment, CmdPublish, CmdPromote, CmdRollback, CmdReleases, CmdDeployments, CmdAddDomain, CmdSetDomain, CmdRemoveDomain, CmdDomains, CmdCrawl, CmdGrant, CmdRevoke, CmdRemoveEnvironment, }
Commands is every command, in the order the schema lists them.
var Reads = []string{CmdGet, CmdList, CmdReleases, CmdDeployments, CmdDomains}
Reads is the commands that change nothing.
Functions ¶
This section is empty.
Types ¶
type BucketSources ¶ added in v1.159.0
type BucketSources interface {
CheckBucket(ctx context.Context, src bucketsource.Source) error
Bucket(ctx context.Context, src bucketsource.Source) ([]sitesvc.InputFile, error)
}
BucketSources reads the files a publish names by a bucket prefix (#2593): CheckBucket refuses a source the caller cannot read, without listing it.
type Content ¶ added in v1.157.0
type Content struct {
Service *sitesvc.Service
// ToolAllowed reports whether a persona holds manage_site: a change to a
// site through manage_asset must not reach further than manage_site does.
ToolAllowed func(persona string) bool
}
Content answers manage_asset's content actions for a site reference (#2588), through the same service manage_site uses.
type Crawler ¶
type Crawler interface {
Crawl(ctx context.Context, req sitecrawl.Request) (*sitecrawl.Result, error)
}
Crawler copies a site into a release's files.
type File ¶
type File struct {
Path string `json:"path"`
// Content is a pointer so an entry with none can be told from an empty
// file: a forgotten content must not blank a page.
Content *string `json:"content,omitempty"`
// Encoding is utf-8 (default) or base64.
Encoding string `json:"encoding,omitempty"`
// Delete removes the path from the base.
Delete bool `json:"delete,omitempty"`
}
File is one file handed to publish.
type Input ¶
type Input struct {
Command string `json:"command"`
// Query, Limit and Offset narrow and page list (#2658).
Query string `json:"query,omitempty"`
Limit int `json:"limit,omitempty"`
Offset int `json:"offset,omitempty"`
Site string `json:"site,omitempty"`
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
OwnerEmail string `json:"owner_email,omitempty"`
// InternalView, Public and Main are pointers so false can be told from
// unset.
InternalView *bool `json:"internal_view,omitempty"`
Public *bool `json:"public,omitempty"`
Main *bool `json:"main,omitempty"`
// MainEnvironment moves the main address on update; "" gives it to none.
MainEnvironment *string `json:"main_environment,omitempty"`
Email string `json:"email,omitempty"`
Persona string `json:"persona,omitempty"`
Environments []string `json:"environments,omitempty"`
Level string `json:"level,omitempty"`
Environment string `json:"environment,omitempty"`
// RequiresApproval is a pointer so false can be told from unset.
RequiresApproval *bool `json:"requires_approval,omitempty"`
// KeepReleases is an environment's release limit: a whole number, a string
// of digits, or "default" (#2602).
KeepReleases json.RawMessage `json:"keep_releases,omitempty"`
// Media, on update, is every resource folder the site serves; nil leaves
// them, [] removes them all (#2591).
Media []site.Mount `json:"media,omitempty"`
From string `json:"from,omitempty"`
To string `json:"to,omitempty"`
Release int `json:"release,omitempty"`
// After places an environment in the site's order (#2617).
After string `json:"after,omitempty"`
// Base makes the files an overlay on that release.
Base int `json:"base,omitempty"`
Note string `json:"note,omitempty"`
Reason string `json:"reason,omitempty"`
Files []File `json:"files,omitempty"`
// Archive is a zip or gzipped tar managed resource, by id or URI.
Archive string `json:"archive,omitempty"`
// FromBucket is the objects under a bucket prefix on an S3 connection the
// caller may use (#2593).
FromBucket *bucketsource.Source `json:"from_bucket,omitempty"`
// Folder is a managed-resource folder, in the library Scope and ScopeID
// name.
Folder string `json:"folder,omitempty"`
Scope string `json:"scope,omitempty"`
ScopeID string `json:"scope_id,omitempty"`
Hostname string `json:"hostname,omitempty"`
Application string `json:"application,omitempty"`
URL string `json:"url,omitempty"`
FormMap map[string]string `json:"form_map,omitempty"`
// Status, Message, BackAt, RedirectTo and KeepPath change what an
// environment answers (#2631, #2632); BackAt is RFC 3339.
Status string `json:"status,omitempty"`
Message string `json:"message,omitempty"`
BackAt string `json:"back_at,omitempty"`
RedirectTo string `json:"redirect_to,omitempty"`
KeepPath *bool `json:"keep_path,omitempty"`
// RenameTo renames the environment (#2630).
RenameTo string `json:"rename_to,omitempty"`
// AgentsMayPromote is read only to refuse it: an administrator sets it in
// the portal (#2643).
AgentsMayPromote *bool `json:"agents_may_promote,omitempty"`
}
Input is the tool's arguments.
type Sources ¶
type Sources interface {
Archive(ctx context.Context, ref string) ([]sitesvc.InputFile, error)
Folder(ctx context.Context, scope, scopeID, path string) ([]sitesvc.InputFile, error)
}
Sources reads the files a publish names by reference.
type Tool ¶
type Tool struct {
Service *sitesvc.Service
Sources Sources
Crawler Crawler
PortalURL string
// Traffic reads each site's traffic for get; nil reports none.
Traffic TrafficReader
// Routing reads each hostname's Site routing status (#2659); nil shows
// none.
Routing *siterouting.Lookup
}
Tool is the registered tool.
func (*Tool) Handle ¶
Handle runs one command with no request to ask the person through: a move that waits on them is filed in Approvals.
func (*Tool) HandleRequest ¶ added in v1.162.0
func (t *Tool) HandleRequest(ctx context.Context, req *mcp.CallToolRequest, in Input) (*mcp.CallToolResult, any, error)
HandleRequest runs one command. A move of an environment people use waits on the person (#2643): their client asks them, or the request is filed.
type TrafficReader ¶ added in v1.162.0
type TrafficReader interface {
ByEnvironment(ctx context.Context, kind, subject, grain string, since time.Time) (map[string]sitetraffic.Counts, []string, error)
}
TrafficReader reads the traffic a site's environments answered (#2647).
type TrafficSummary ¶ added in v1.162.0
type TrafficSummary struct {
Range string `json:"range"`
Recording bool `json:"recording"`
Total sitetraffic.Totals `json:"total"`
Environments map[string]sitetraffic.Totals `json:"environments"`
}
TrafficSummary is what get reports of a site's last 24 hours (#2647): requests and latency for the whole site and for each environment, so an agent asked whether the site is slow answers from it.