Documentation
¶
Overview ¶
Package artifact keeps Magpie Artifacts: pages an agent makes for the user to look at or use (a report, a chart, a small app), kept on this computer with every version, and served by the gateway at /a/<id>/.
Claude Code's own Artifact tool keeps its pages with the claude.ai account that made them, so a page made before magpie switched the Claude account doesn't open under the next one. These are magpie's, whichever account or agent made them.
An artifact is a folder under Dir named by its id, a random, unguessable name: meta.json says what it is and lists its versions, and v<N>/ holds version N's files, the page as index.html beside the files it uses. A version is written whole into a folder of its own and never changed after; a publish that leaves a file out keeps the one before (linked, or copied where links can't be made).
Index ¶
- Constants
- Variables
- func AppIconPNG(a *Artifact, size int) ([]byte, error)
- func AppWorkerJS(lang string) []byte
- func AssetLimit(t string) int
- func Assets(id string) ([]Asset, AssetUsage, error)
- func CheckAsset(body []byte, t string) ([]byte, error)
- func CheckCommentText(s string) (string, error)
- func CheckPath(p string, doc bool) ([]string, error)
- func CleanPath(p string) (string, error)
- func CloseDBs()
- func Collections(id string) (map[string]int, error)
- func CommentsComposerOnly(c Capabilities) bool
- func CommentsStamp(id string) string
- func DataVersion(id string) int64
- func Delete(id string) error
- func DeleteAsset(id, aid string) (deleted bool, err error)
- func DeleteComment(id, tid, cid string) error
- func DeleteThread(id, tid string) error
- func FileSHA(id string, n int, name string) (sum string, ok bool, err error)
- func FilesDir(c Capabilities, cwd string) (string, error)
- func Guide(names []string) (string, error)
- func GuideNames() []string
- func Manifest(a *Artifact, home, api string) []byte
- func OwnerLink(ctx context.Context, id string) (string, error)
- func PageTitle(page []byte) string
- func PageToken(id string) (string, error)
- func PageTokenOK(id, t string) bool
- func Resolve(id, tid string, resolved bool) error
- func RestoreDocs(id string, docs []SharedDoc) error
- func SanitizeSVG(body []byte) ([]byte, error)
- func Served(page []byte) []byte
- func SetRun(id, tid string, r *Run) error
- func ShellCSP(nonce string) string
- func ShellPage(c ShellConfig) (page []byte, nonce string)
- func ShellToken(id string) (string, error)
- func ShellTokenOK(id, t string) bool
- func Stats(id string) (docs int, bytes int64, err error)
- func Unshare(ctx context.Context, id string) error
- func ValidAssetID(s string) bool
- func ValidID(id string) bool
- func Watch(id string) (<-chan Change, func())
- func Whole(page []byte) bool
- func WithRuntime(page []byte, c *RuntimeConfig) []byte
- type Anchor
- type Artifact
- type ArtifactConfig
- type Asset
- type AssetUsage
- type AssetsConfig
- type Capabilities
- type Change
- type Comment
- type CommentError
- type CommentsConfig
- type ConflictPath
- type DB
- func (db *DB) Acquire(p, holder string, ttl time.Duration, data map[string]any) (*Lease, error)
- func (db *DB) Batch(ops []Op) error
- func (db *DB) Delete(p string) error
- func (db *DB) Get(p string) (*Doc, error)
- func (db *DB) Run(q Query) ([]*Doc, error)
- func (db *DB) Set(p string, data map[string]any) error
- func (db *DB) Update(p string, data map[string]any) error
- type DBConfig
- type DBError
- type Doc
- type FileConflict
- type FileLimit
- type FilesConfig
- type Filter
- type Lease
- type Level
- type MCPConfig
- type MCPServerDecl
- type NewThread
- type Op
- type Publish
- type Query
- type RoomConfig
- type Rule
- type Run
- type RuntimeConfig
- type SampleConfig
- type Share
- type SharedDoc
- type ShellConfig
- type Thread
- type UserConfig
- type Version
- type Viewer
Examples ¶
Constants ¶
const ( AppManifest = "app.webmanifest" AppWorker = "app-sw.js" // AppIcon is the icon's name before its size: app-icon-192.png AppIcon = "app-icon-" )
An artifact installs as an app from the browser it opens in: its page's folder is the app's scope, with a manifest, an icon drawn from its title, and a service worker that answers when magpie isn't running (docs/subsystems/artifacts.md, "Install as app").
const ( // MaxAsset is the most an asset may be; an SVG MaxSVGAsset, a // stylesheet or script MaxCodeAsset MaxAsset = 20 << 20 MaxSVGAsset = 2 << 20 MaxCodeAsset = 16 << 20 // MaxAssets and MaxAssetBytes are an artifact's budget MaxAssets = 1000 MaxAssetBytes = 1 << 30 )
const ( // MaxCommentText is the most a comment's text holds, in bytes MaxCommentText = 4096 // MaxThreads is the most threads an artifact keeps, MaxReplies the // most comments a thread does MaxThreads = 500 MaxReplies = 200 )
const ( // MaxPage is the most a page may hold, MaxFile a file beside it, and // MaxVersion a version's files together (the page included) MaxPage = 16 << 20 MaxFile = 16 << 20 MaxVersion = 64 << 20 // MaxFiles is the most files a version holds besides its page MaxFiles = 255 )
const BlobPath = "/_blob/"
BlobPath is where an asset is served, by its id alone.
MaxShared is the most a shared version's files hold together, as usemagpie.ai takes (site/shares.js MAX_BYTES).
const Page = "index.html"
Page is the name a version's page is kept and served under.
const PageAgent = "page"
PageAgent is the Agent of a version the page published itself (the artifact capability), as the user viewing it.
Variables ¶
var ( ErrAssetRequest = errors.New("not an asset") ErrAssetType = errors.New("not a type an asset may be") ErrAssetQuota = errors.New("the artifact's assets are full") )
the asset refusals, by the code the page reads (ErrTooLarge is too_large)
var ( ErrNotFound = errors.New("no such artifact") // ErrConflict: the artifact has a version newer than the one the // publish was built on ErrConflict = errors.New("the artifact has a newer version than the one read") // ErrTooLarge and ErrInvalid are a publish refused for its size and // for what it holds (a page that isn't text, a bad path): its error // Is one of them, with its own words ErrTooLarge = errors.New("too large to publish") ErrInvalid = errors.New("not publishable") )
var AppIconSizes = []int{192, 512}
AppIconSizes are the sizes the manifest lists, which browsers pick from.
var AssetTypes = []string{
"image/png", "image/jpeg", "image/gif", "image/webp", "image/svg+xml",
"video/mp4", "video/webm", "application/pdf",
"font/woff2", "font/woff", "font/ttf", "font/otf",
"text/csv", "text/markdown", "application/json", "text/plain", "text/css", "text/javascript",
}
AssetTypes are the types an asset may be, exactly as spelled: no parameters, no aliases.
Dir is the folder artifacts are kept in; a variable for tests.
ErrSharedGone is a shared link usemagpie.ai took down on its side (a page reported): the artifact isn't shared any more.
var ServedCaps = []string{"artifact", "assets", "comments", "db", "dictation", "downloads", "files", "mcp", "room", "sample", "self", "tts", "user"}
ServedCaps are the capabilities the page runtime gives a page that declares them; permissions is built in and never declared. self is artifact's former name, and resolves the same namespace.
if s := os.Getenv("MAGPIE_SHARE_SITE"); s != "" { return strings.TrimRight(s, "/") } if testing.Testing() { return "" } return "https://usemagpie.ai" }
ShareSite is where artifacts are shared. MAGPIE_SHARE_SITE moves it, and a test names its own: a test never shares on the real site.
SharedCaps are the capabilities a shared copy is served on usemagpie.ai: its data, its room, and who is viewing.
Functions ¶
func AppIconPNG ¶
AppIconPNG draws the artifact's icon at size: a rounded square in its colour, on the platform's icon grid (a margin around it, as macOS's icons have), with the title's first letter, or a page where the font has no such letter.
func AppWorkerJS ¶
AppWorkerJS is the app's service worker: it leaves every request alone but the app's own window opening, and answers that with a page saying to open magpie when magpie can't be reached. lang is magpie's language setting; "system" (or none) takes the browser's.
The window is fetched by navigation preload, never by the worker's own fetch: that one goes as Sec-Fetch-Dest empty, where magpie serves the page alone, not the shell that frames it. A browser with no preload gets no offline page, and the network as before.
func Assets ¶
func Assets(id string) ([]Asset, AssetUsage, error)
Assets is artifact id's assets, oldest first, and its budget.
func CheckAsset ¶
CheckAsset is body as it is stored under type t (an SVG sanitized), or why it can't be.
func CheckCommentText ¶
CheckCommentText is the contract's rule for a comment's text: plain text, not empty, at most 4 KiB, no control characters but newlines and tabs.
func CheckPath ¶
CheckPath is a store path's segments; doc says whether it names a document (an even number of segments) or a collection (odd).
Example ¶
_, err := CheckPath("tasks", true)
fmt.Println(err)
Output: invalid_argument: "tasks" has 1 segments, so it is a collection: a document's path has an even number
func CleanPath ¶
CleanPath is a published path as kept: forward slashes, relative, nothing that climbs out or names the page; an error says why not.
func CloseDBs ¶
func CloseDBs()
CloseDBs lets go of every open data.db. Windows can't remove a folder while a file in it is open, so a test's folder needs this first.
func Collections ¶
Collections are the store's collections, with how many documents each holds, for an agent finding its way.
func CommentsComposerOnly ¶
func CommentsComposerOnly(c Capabilities) bool
CommentsComposerOnly is whether the version's page declares comments as composer_only: it opens the composer and writes nothing.
func CommentsStamp ¶
CommentsStamp moves whenever the artifact's comments are written, by this process or another: their file's time and size.
func DataVersion ¶
DataVersion changes when another connection, in this process or another, has written artifact id's store; 0 when it has none.
func Delete ¶
Delete takes the artifact and every version of it away, its shared link first: one that can't be taken down keeps the artifact, so its token isn't lost with it.
func DeleteAsset ¶
DeleteAsset takes asset aid away from artifact id for good; deleted is false when it holds none by that id.
func DeleteComment ¶
DeleteComment deletes one comment of thread tid; the thread goes with its last.
func DeleteThread ¶
DeleteThread deletes thread tid and every comment in it.
func FileSHA ¶
FileSHA is the sha256, in hex, of version n's (0: the newest) file name (Page or "" for the page); ok is false when it has none.
func FilesDir ¶
func FilesDir(c Capabilities, cwd string) (string, error)
FilesDir is the folder a version declaring files reads: its project when that is an absolute path, else cwd, the folder the publishing agent worked in. It is refused when there is none, when it is a disk's root or the home folder or holds it, and when it isn't a folder.
func Guide ¶
Guide is the guide for names, every capability when there are none; "self" is artifact's. An error names one it doesn't know.
func GuideNames ¶
func GuideNames() []string
GuideNames are the capabilities the guide covers, in its order.
func Manifest ¶
Manifest is the web app manifest of the artifact at home, its page's folder (/a/<id>/); api is that folder's _api, where the icons are.
func OwnerLink ¶
OwnerLink is a link that opens the shared page as its owner, once: usemagpie.ai trades its code for a key the browser keeps.
func PageToken ¶
PageToken is what artifact id's page sends to reach its store: only the page magpie served knows it, so another page on this computer, or another artifact's, can't read or write it.
func PageTokenOK ¶
PageTokenOK is whether t is artifact id's page token.
func RestoreDocs ¶
RestoreDocs makes artifact id's store hold docs and nothing else, each at its own version and time, all or none. A document that isn't one the store takes (its path, its body, the store's size) refuses the whole of it, and the store stays as it was.
func SanitizeSVG ¶
SanitizeSVG is an SVG upload as it is stored, as claude.ai's assets keep one: scripts, event handlers, <foreignObject>, <style> and <link>, animation, a <use> of another file, and javascript: and data: URLs are taken out, and what is left is written out again. It is served as an image, so nothing is left in it that runs or reaches out once it is opened as a document.
func Served ¶
Served is the page as a browser is given it: one written as a fragment, with no doctype, is put in a document of its own with a charset, a viewport and the base styles a page without them lacks, so it doesn't render in quirks mode with the browser's defaults. A page with its doctype is given as written.
func ShellCSP ¶
ShellCSP is the shell's Content-Security-Policy: its own script and style alone, the page in a frame from magpie's address, and nothing framing it.
func ShellPage ¶
func ShellPage(c ShellConfig) (page []byte, nonce string)
ShellPage is the shell's HTML, and the nonce its CSP must allow.
func ShellToken ¶
ShellToken is the token artifact id's viewer shell holds: it reads and writes the artifact's comments, and nothing else. The page holds its own (PageToken), which the shell's never is.
func ShellTokenOK ¶
ShellTokenOK is whether t is artifact id's shell token.
func Unshare ¶
Unshare takes the artifact's shared link down; one not shared, or taken down on usemagpie.ai already, is done.
func ValidAssetID ¶
ValidAssetID is whether s is one an asset can have.
func Watch ¶
Watch gives the store's writes to artifact id as they are made in this process; another process's (the CLI's) show in DataVersion.
func Whole ¶
Whole is whether page is a whole document, its doctype first, as a page that publishes itself sends it.
func WithRuntime ¶
func WithRuntime(page []byte, c *RuntimeConfig) []byte
WithRuntime is the served page with the runtime in it, ahead of the page's own scripts: right after <head>, else <html>, else the doctype, else first.
Types ¶
type Anchor ¶
type Anchor struct {
Path string `json:"path,omitempty"`
X float64 `json:"x"`
Y float64 `json:"y"`
Name string `json:"name,omitempty"`
}
Anchor is where a thread sits on the page: an element, by the path the shell's click or the page's anchorFor makes, and a point in it (x, y, each 0 to 1 of the element's box). Name is a page's own name for the spot (customAnchors), when it places its pins itself.
func CheckAnchor ¶
CheckAnchor is a's own copy, checked: a path or a name, and a point in the element's box.
type Artifact ¶
type Artifact struct {
ID string `json:"id"`
Title string `json:"title"`
Description string `json:"description,omitempty"`
Created time.Time `json:"created"`
Updated time.Time `json:"updated"`
Versions []Version `json:"versions"`
}
Artifact is one artifact as meta.json keeps it.
func File ¶
File is where version n's (0: the newest) file name is on disk; name "" or Page is the page.
func List ¶
List is every artifact, the most recently updated first. One whose meta.json can't be read is left out, and said in the error beside the rest.
func PublishPage ¶
PublishPage writes a new artifact, or a new version of one.
type ArtifactConfig ¶
type ArtifactConfig struct {
Publish *bool `json:"publish,omitempty"`
}
ArtifactConfig is the artifact capability's declaration (and self's, its former name): {publish: false} keeps the page from saving itself.
func ParseArtifactConfig ¶
func ParseArtifactConfig(raw json.RawMessage) (*ArtifactConfig, error)
ParseArtifactConfig reads the artifact capability's declaration.
type Asset ¶
type Asset struct {
ID string `json:"id"`
ContentType string `json:"contentType"`
Size int64 `json:"sizeBytes"`
Created time.Time `json:"createdAt"`
}
Asset is one stored asset, as assets.json keeps it.
type AssetUsage ¶
type AssetUsage struct {
Files int `json:"files"`
Bytes int64 `json:"bytes"`
MaxFiles int `json:"maxFiles"`
MaxBytes int64 `json:"maxBytes"`
}
AssetUsage is how much of an artifact's budget its assets take.
type AssetsConfig ¶
type AssetsConfig struct {
Upload string `json:"upload,omitempty"`
}
AssetsConfig is the assets capability's declaration: upload "interact" lets people who can't edit upload too, on claude.ai; here the page's one viewer is its owner, who always may.
func ParseAssetsConfig ¶
func ParseAssetsConfig(raw json.RawMessage) (*AssetsConfig, error)
ParseAssetsConfig reads the assets capability's declaration.
type Capabilities ¶
type Capabilities map[string]json.RawMessage
Capabilities is a version's declaration, by name.
func ParseCapabilities ¶
func ParseCapabilities(raw json.RawMessage) (Capabilities, error)
ParseCapabilities reads a declaration as a publish gives it: nil for none given (the one before is kept), an empty map for {} (cleared).
func (Capabilities) Has ¶
func (c Capabilities) Has(name string) bool
Has is whether the declaration names capability name.
func (Capabilities) MCP ¶
func (c Capabilities) MCP() *MCPConfig
MCP is the version's mcp manifest, nil if it declares none.
func (Capabilities) PagePublishes ¶
func (c Capabilities) PagePublishes() (publishes, declared bool)
PagePublishes is whether the version's page may publish itself: it declares artifact (or self) without {publish: false}. declared is whether it declares either at all.
func (Capabilities) SampleImages ¶
func (c Capabilities) SampleImages() bool
SampleImages is whether the version's page may send images with its sample calls.
type Change ¶
type Change struct {
Artifact string
Paths []string
// Version, when set, is a new version published: no data changed
Version int
// Comments: the artifact's comments changed, and no data did
Comments bool
}
Change is a write the store made: the paths it touched.
type Comment ¶
type Comment struct {
ID string `json:"id"`
Author string `json:"author"`
// Agent, for a comment an agent wrote: who (claude, codex, …)
Agent string `json:"agent,omitempty"`
Text string `json:"text"`
At time.Time `json:"at"`
// Sent: the comment was sent to an agent
Sent bool `json:"sent,omitempty"`
}
Comment is one comment in a thread.
type CommentError ¶
type CommentError struct {
Code, Message string
}
CommentError is a comment call refused, with the contract's code.
func (*CommentError) Error ¶
func (e *CommentError) Error() string
type CommentsConfig ¶
type CommentsConfig struct {
ComposerOnly bool `json:"composer_only,omitempty"`
CustomAnchors bool `json:"customAnchors,omitempty"`
}
CommentsConfig is the comments capability's declaration: composer_only grants only openComposer and anchorFor, which write nothing; customAnchors adds customAnchors().
func ParseCommentsConfig ¶
func ParseCommentsConfig(raw json.RawMessage) (*CommentsConfig, error)
ParseCommentsConfig reads the comments capability's declaration.
type ConflictPath ¶
type ConflictPath struct {
Path string `json:"path"`
Expected *string `json:"expected"`
Actual *string `json:"actual"`
}
ConflictPath is a file whose IfMatch no longer held: Actual is its sha256 now, nil when it isn't there.
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB is one artifact's store, as one viewer reaches it.
func OpenDB ¶
OpenDB is artifact id's store as viewer who reaches it from version n (0: the newest), under the rules the db declaration in force there sets (DBRules). It needs no db declaration: an agent reads and seeds the store of a page that declares one later.
func (*DB) Acquire ¶
Acquire takes a short lease on the document at p for holder, when no one else holds it, merging data into the document then.
func (*DB) Delete ¶
Delete takes the document at p away; one not there is done. Documents nested below it stay.
func (*DB) Get ¶
Get is the document at p, nil when there is none or the viewer can't see it: the two are the same to the viewer.
type DBConfig ¶
type DBConfig struct {
Rules []Rule `json:"rules,omitempty"`
}
DBConfig is the db capability's declaration.
func DBRules ¶
DBRules is the db declaration in force for artifact a's version n (0: the newest): that version's, or the newest's when it declares none.
func ParseDBConfig ¶
func ParseDBConfig(raw json.RawMessage) (*DBConfig, error)
ParseDBConfig reads and checks the db capability's declaration, as claude.ai checks it at publish.
type DBError ¶
DBError is a store call's failure, by the code claude.ai's runtime gives a page (invalid_argument, resource_exhausted, quota_exceeded, unavailable).
type Doc ¶
type Doc struct {
Path string `json:"path"`
ID string `json:"id"`
Data map[string]any `json:"data"`
Version int64 `json:"version"`
Updated time.Time `json:"updated"`
}
Doc is one document as the store gives it.
type FileConflict ¶
type FileConflict struct {
Newest int
Paths []ConflictPath
}
FileConflict refuses a publish whose IfMatch didn't hold; it is an ErrConflict.
func (*FileConflict) Error ¶
func (c *FileConflict) Error() string
func (*FileConflict) Is ¶
func (c *FileConflict) Is(err error) bool
type FileLimit ¶
type FileLimit struct{ Max, Would int }
FileLimit refuses a version that would hold more than Max files besides its page; it is an ErrInvalid.
type FilesConfig ¶
type FilesConfig struct {
Project string `json:"project,omitempty"`
}
FilesConfig is the files capability's declaration. Claude's project is a Claude Code project's id; here it is a folder on this computer, given as an absolute path, and anything else (Claude's "chan_..." among them) is the folder the publishing agent worked in.
func ParseFilesConfig ¶
func ParseFilesConfig(raw json.RawMessage) (*FilesConfig, error)
ParseFilesConfig reads the files capability's declaration.
type Lease ¶
type Lease struct {
Acquired bool `json:"acquired"`
Version int64 `json:"version,omitempty"`
ExpiresAt time.Time `json:"expiresAt,omitzero"`
Holder string `json:"holder,omitempty"`
}
Lease is an acquire's answer.
type MCPConfig ¶
type MCPConfig struct {
Servers []MCPServerDecl `json:"servers"`
}
MCPConfig is the mcp capability's declaration: the manifest of the servers, and each one's tools, the page may call. A server is a Library MCP server's name, or host:<name> for one on this computer, which in magpie is every Library server too.
func ParseMCPConfig ¶
func ParseMCPConfig(raw json.RawMessage) (*MCPConfig, error)
ParseMCPConfig reads the mcp capability's declaration.
type MCPServerDecl ¶
MCPServerDecl is one server of the mcp manifest.
type NewThread ¶
type NewThread struct {
Anchor *Anchor
Label, Detail, Quote string
Version int
Author, Agent, Text string
Sent bool
}
NewThread is what starts a thread.
type Op ¶
type Op struct {
Op string `json:"op"`
Path string `json:"path"`
Data map[string]any `json:"data,omitempty"`
}
Op is one write of a batch: set, update or delete.
type Publish ¶
type Publish struct {
ID string
Title string // used when the page has no <title> of its own
Description string
Label string
Agent string
Cwd string
// Page is the page itself; on an update nil keeps the one before
Page []byte
// Files are the files beside the page, by published path; on an
// update the files left out are kept, and a nil value removes one
Files map[string][]byte
// Base, when set, is the version the publisher last read: a publish
// over a newer one is refused (ErrConflict)
Base int
// IfMatch holds files to what the publisher last read, by published
// path (Page for the page): the sha256 (FileSHA) each still has, nil
// for one that isn't there yet. A file that no longer matches
// refuses the publish with a *FileConflict.
IfMatch map[string]*string
// Capabilities: nil keeps the version before's, an empty map
// clears them, any other is the whole set (ParseCapabilities)
Capabilities Capabilities
}
Publish is what a publish asks for. With ID empty a new artifact is made; with it, the artifact gets a new version.
type Query ¶
type Query struct {
Collection string `json:"collection"`
Where []Filter `json:"where,omitempty"`
OrderBy string `json:"orderBy,omitempty"`
Desc bool `json:"desc,omitempty"`
Limit int `json:"limit,omitempty"`
}
Query is a read of one collection.
type RoomConfig ¶
RoomConfig is the room capability's declaration: the event topics opened below Editors (admin), each to "interact" or "admin". Presence is anyone's in the room.
func ParseRoomConfig ¶
func ParseRoomConfig(raw json.RawMessage) (*RoomConfig, error)
ParseRoomConfig reads the room capability's declaration.
type Rule ¶
type Rule struct {
Path string `json:"path"`
Read string `json:"read,omitempty"`
Write string `json:"write,omitempty"`
}
Rule is one access rule of the db capability: the least level that reads and that writes at Path and below.
type Run ¶
type Run struct {
Agent string `json:"agent"`
// State is working, done or failed
State string `json:"state"`
Error string `json:"error,omitempty"`
At time.Time `json:"at"`
// Version is the version the run published, when it did
Version int `json:"version,omitempty"`
}
Run is an agent at work on a thread's request.
type RuntimeConfig ¶
type RuntimeConfig struct {
// API is where the page's store calls go: <page's folder>_api
API string `json:"api"`
Token string `json:"token"`
// Caps are the served capabilities the version declares, by name,
// with their declarations
Caps map[string]any `json:"caps"`
Viewer struct {
ID string `json:"id"`
} `json:"viewer"`
// Version is the version the page is; Pinned, that its address names
// it (<id>@<n>/), so a newer one doesn't reload it. Home is the
// artifact's own address, where a publish from a pinned view goes.
Version int `json:"version,omitempty"`
Pinned bool `json:"pinned,omitempty"`
Home string `json:"home,omitempty"`
// Origin is magpie's origin, as the browser names it: the viewer
// shell's, which the page's runtime speaks to (shell.js)
Origin string `json:"origin,omitempty"`
// declares of SharedCaps is served there (site/live.js), once the
// link's page hands the frame a session; the rest resolves null.
Shared bool `json:"shared,omitempty"`
}
RuntimeConfig is what the page runtime is given about its page.
func PageRuntime ¶
func PageRuntime(a *Artifact, n int, api string) (*RuntimeConfig, error)
PageRuntime is the runtime config for artifact a's version n (0: the newest), its store calls going to api.
func SharedRuntime ¶
func SharedRuntime(v *Version) *RuntimeConfig
SharedRuntime is the runtime a shared copy of version v runs (v nil: a page that declares nothing): window.claude is there, so a page written for it runs; what it declares of SharedCaps waits for the link's session, and every other capability is null, so the page shows what it shows without them.
type SampleConfig ¶
type SampleConfig struct {
Images bool `json:"images,omitempty"`
}
SampleConfig is the sample capability's declaration: {images: true} lets the page send images with its calls.
func ParseSampleConfig ¶
func ParseSampleConfig(raw json.RawMessage) (*SampleConfig, error)
ParseSampleConfig reads the sample capability's declaration.
type Share ¶
type Share struct {
// Version is the artifact's version the link shows
// page's data, which goes back to the store here when it stops being
// shared, whatever the version shown then declares
Data bool `json:"data,omitempty"`
// never kept
Note string `json:"-"`
}
Share is an artifact's shared link, as share.json keeps it.
func ShareLatest ¶
ShareLatest shares the artifact's newest version: at a new link, or, shared already, at its link in place of the version it showed.
type SharedDoc ¶
type SharedDoc struct {
}
SharedDoc is one document as a share carries it: site/livedb.js's dump and seed.
type ShellConfig ¶
type ShellConfig struct {
// API is the page's <folder>_api; Token, the shell's token
API string `json:"api"`
Token string `json:"token"`
ID string `json:"id"`
Title string `json:"title"`
// Src is the page the shell frames: the address it was opened at;
// the shell adds the fragment, which the server never sees
Src string `json:"src"`
// Version is the version shown; Pinned, that the address names it
Version int `json:"version"`
Pinned bool `json:"pinned,omitempty"`
// Origin is magpie's origin, as the browser names it: the page's
// runtime posts to it alone
Origin string `json:"origin"`
// Lang is magpie's language setting (system, en, zh, zh-TW, ja, de)
Lang string `json:"lang,omitempty"`
// App is the newest page's _api, where its app manifest, icons and
// service worker are (app.go): a pinned version's shell takes its
// icon, and only the newest's installs
App string `json:"app,omitempty"`
}
ShellConfig is what the shell is given.
type Thread ¶
type Thread struct {
ID string `json:"id"`
// Anchor is nil for a comment on the artifact as a whole
Anchor *Anchor `json:"anchor,omitempty"`
// Label names the spot in a few words; Detail says more, for the
// agent; Quote is the text the person selected there
Label string `json:"label,omitempty"`
Detail string `json:"detail,omitempty"`
Quote string `json:"quote,omitempty"`
// Version is the version the thread was started on
Version int `json:"version"`
Author string `json:"author"`
Created time.Time `json:"created"`
Resolved bool `json:"resolved,omitempty"`
Comments []Comment `json:"comments"`
Run *Run `json:"run,omitempty"`
}
Thread is a comment and its replies, at one spot on the page.
func StartThread ¶
StartThread starts a thread on artifact id with its first comment.
type UserConfig ¶
type UserConfig struct {
Scopes []string `json:"scopes,omitempty"`
}
UserConfig is the user capability's declaration.
func ParseUserConfig ¶
func ParseUserConfig(raw json.RawMessage) (*UserConfig, error)
ParseUserConfig reads the user capability's declaration.
type Version ¶
type Version struct {
N int `json:"n"`
At time.Time `json:"at"`
Label string `json:"label,omitempty"`
// Agent is who published it, as the gateway knew the caller
Agent string `json:"agent,omitempty"`
// Cwd is the folder the agent worked in, when it was known: where a
// comment sent to an agent finds the session that published it
Cwd string `json:"cwd,omitempty"`
// Files are the version's files besides the page, by published path
Files []string `json:"files,omitempty"`
Size int64 `json:"size"`
// Capabilities are what the page may do beyond static HTML (caps.go)
Capabilities Capabilities `json:"capabilities,omitempty"`
// FilesDir is the folder the page reads with files (FilesDir in
// caps.go), set at publish; a publish with no folder of its own (a
// page publishing itself) keeps the one before
FilesDir string `json:"filesDir,omitempty"`
}
Version is one publish of an artifact.
type Viewer ¶
Viewer is who reaches into an artifact's data: the person viewing its page, at their level, or an agent, which reaches everything.
func LocalViewer ¶
LocalViewer is the person at this computer, as the store knows them: every artifact's owner.