exportrefs

package
v1.134.1 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package exportrefs is platform.export's references= argument (#1834): what it may hold, the manage_asset call that declares it on the asset an export wrote, and the reading of a document, and of a script's source, for the references nothing declares.

A document a script publishes names a managed resource or another asset by its reference, and the viewing surfaces rewrite a reference into a working URL only when the asset declares it. The declaration is made through manage_asset rather than here, so the author-can-read check and the grant notice are the ones an agent's save gets. It is its own package, as internal/platform/exporttable is, for scriptrun's size budget.

Index

Constants

View Source
const (
	Tool = "manage_asset"
	Call = Tool + " action=update"
)

Tool is the tool a declaration is made through, the one an agent declares an asset's references with, and Call is how the write reads in a draft's list.

View Source
const Keyword = "references"

Keyword is the platform.export argument a declaration is passed as.

Variables

View Source
var ErrNotADocument = errors.New("references are declared on a portal document, the output of a string body " +
	"written to \"portal\"; this output has no markup to reference anything from")

ErrNotADocument refuses a declaration on an output that has no markup to reference anything from: a bucket object or a library file has no references to record, and a tabular output is serialized by the platform.

Functions

func Args

func Args(assetID string, refs []string) map[string]any

Args is the manage_asset call that declares refs on the asset.

func Declares

func Declares(call *syntax.CallExpr) bool

Declares reports whether one platform.export call passes references=.

func LogLine

func LogLine(output string, undeclared []string) string

LogLine is the run log's record of the references an output's body names and does not declare, so a scheduled run's history says which pictures will not load whether or not the script printed its result.

func Named

func Named(body string) []string

Named returns every distinct reference string a textual body names: each managed resource by its mcp:// URI, then each asset by its mcp:asset:<id> reference, both in the order they first appear.

It recognizes the default resource scheme only. A deployment that renamed its scheme (resources.managed.uri_scheme) writes URIs this does not see, so a caller must treat an empty result as "found none", never as "there are none". Declaration is unaffected: it is manage_asset's, which takes the deployment's scheme.

It is the reading the serving rewrite would need a declaration for, so a surface can tell an author which references in a document will be served as written and resolve to nothing (#1834). It grants nothing: a string found here is a string, and only a declaration makes it load.

func Parse

func Parse(v any) ([]string, error)

Parse reads a references= argument, already converted to plain Go values, into the list of reference strings, each trimmed as the rewrite will match it. An empty list is returned as one: it is a decision to clear the asset's references.

func Undeclared

func Undeclared(body string, declared []string) []string

Undeclared returns the reference strings body names that declared does not list, in the order Named finds them. Each declared entry is trimmed first, as a declaration is recorded.

Types

type Literal

type Literal struct {
	URI  string
	Line int
}

Literal is one reference string a script's source writes that no export declares, and the line it is written on.

func InSource

func InSource(file *syntax.File, exportMember, callMember string) []Literal

InSource returns each reference string the source writes as a literal that no platform.export declares in references=, once, at its first line. exportMember and callMember are the platform module's export and call members.

The string is read wherever it is written, because the usual shape assigns it to a name first (LOGO = "mcp://...") and formats it into the markup later, where no static read can follow it. A literal is not proof the string reaches a document, so three readings return nothing rather than guess. A script with no export writes no document, so a URI in it is handed to a tool. An export whose references= is computed declares a list this read cannot see; a name bound once to a string literal is read as that string. And a literal inside a platform.call is an argument to that tool, not markup, and is not read.

func (Literal) Hint

func (l Literal) Hint() string

Hint names the fix, on the export that writes the document.

func (Literal) Message

func (l Literal) Message() string

Message and Hint are what an author reads about one undeclared literal.

Jump to

Keyboard shortcuts

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