Documentation
¶
Overview ¶
Package apps is harnessly's apps: a package an author writes once (a Claude Code plugin plus the manifest harnessly/app.json) that a person installs on a machine and turns on in a chat, a pane tab, a full screen of its own or a Sinopia document. A plugin is an app without views.
This file reads and checks the manifest. The checks are the ones `harnessly app validate` reports and an install refuses on: every problem carries the path of the field (targets[2], agent.tools.deny[0]) so an author, or an agent editing the package, can find it.
Index ¶
- Constants
- Variables
- func CompareVersions(a, b string) int
- func LoadPackage(dir string) (*Package, Problems)
- func ParseManifest(raw []byte) (*Manifest, Problems)
- func PluginName(id string) string
- func Scaffold(dir, id, name, template string) error
- func SnapshotIntact(path string, body []byte) bool
- type Activation
- type Agent
- type Backend
- type Call
- type Chat
- type ContextItem
- type Decision
- type InstallOptions
- type Installed
- type Launcher
- type MCPServer
- type Manifest
- type Network
- type Package
- type Problem
- type Problems
- type Range
- type Registry
- type Secret
- type Snapshot
- type SnapshotApp
- type ToolPolicy
- type Verdict
- type View
Constants ¶
const ( TrustDeclarative = "declarative" TrustSandboxed = "sandboxed" TrustTrusted = "trusted" )
Trust levels: what a package may carry. A declarative app is text only (instructions, skills, commands, remote MCP servers, views as static files); a sandboxed one also runs its views' scripts in the sandboxed frame; a trusted one may start local processes (stdio MCP servers, validator commands) and is installed by hand only.
const ( TargetChat = "chat" TargetPane = "pane" TargetApp = "app" )
Targets an app works in. sinopia.<kind> names one Sinopia document type, sinopia.* all of them.
const ( OnManual = "manual" OnView = "view" OnDocument = "document" OnAlways = "always" )
Activations: how an app turns on.
const ( // MaxPackageBytes is the most a package may weigh, every file counted. MaxPackageBytes = 50 << 20 // MaxInstructionsBytes is the most the always-in-context instructions may weigh; past InstructionsWarnBytes the // check warns that every turn pays for them. MaxInstructionsBytes = 16 << 10 InstructionsWarnBytes = 4 << 10 )
const FirstVersion = "0.16.36"
FirstVersion is the first host version with apps: the range a new package starts with.
const GuardTimeoutSeconds = 15
GuardTimeoutSeconds is how long Claude waits for the guard. The guard reads one local file and answers at once; one that could not read it refuses the call.
const ManifestPath = "harnessly/app.json"
ManifestPath is where the manifest lives inside a package.
Variables ¶
var ( // ErrNotInstalled: no installed app has that id. ErrNotInstalled = errors.New("apps: not installed") // ErrInvalid: the package has errors; the Problems say which. ErrInvalid = errors.New("apps: the package has errors") // ErrHostVersion: the app does not work with this host's version. ErrHostVersion = errors.New("apps: needs another harnessly version") )
var Templates = []string{"chat", "pane-chat"}
Templates are the starting points of `harnessly app new --template`.
Functions ¶
func CompareVersions ¶
CompareVersions orders two app versions (1.2.0 < 1.10.0); a version that does not parse sorts first.
func LoadPackage ¶
LoadPackage reads the package in dir and checks it whole. The package comes back whenever the manifest could be read, with the problems found; nil means there is no manifest to read.
func ParseManifest ¶
ParseManifest reads the manifest. A syntax error, or a field of the wrong type, comes back as one problem with the line it stands on; otherwise the manifest is checked and every problem found is returned at once.
func PluginName ¶
PluginName is the Claude Code plugin name of an app: its skills are <plugin>:<skill> to the agent.
func SnapshotIntact ¶
SnapshotIntact says whether a snapshot's bytes are the ones its name was made from (writeByContent): a snapshot changed after the launch is not one the guard decides by.
Types ¶
type Activation ¶
type Activation struct {
On []string `json:"on"`
OpenView string `json:"openView,omitempty"`
Template string `json:"template,omitempty"`
}
Activation is how the app turns on and what it opens when it does.
type Agent ¶
type Agent struct {
Instructions string `json:"instructions,omitempty"`
Skills []string `json:"skills,omitempty"`
MCP []string `json:"mcp,omitempty"`
Context []ContextItem `json:"context,omitempty"`
Tools *ToolPolicy `json:"tools,omitempty"`
Validators string `json:"validators,omitempty"`
Flow string `json:"flow,omitempty"`
Exclusive bool `json:"exclusive,omitempty"`
}
Agent is the agent profile: what the agent of a chat gets while the app is on in it.
type Call ¶
type Call struct {
// Tool is the agent's own name of the tool: Bash, Edit, mcp__bank-cashback__create,
// mcp__plugin_acme-cashback_bank-cashback__create.
Tool string
// Input is the call's arguments: for Bash, command; for the file tools, file_path.
Input map[string]any
}
Call is one tool call as the agent's hook reports it.
type Chat ¶
type Chat struct {
Commands []string `json:"commands,omitempty"`
Cards []string `json:"cards,omitempty"`
}
Chat is what the app adds to the chat.
type ContextItem ¶
type ContextItem struct {
ID string `json:"id"`
Tool string `json:"tool"`
Mode string `json:"mode"`
}
ContextItem is a source the agent reads on demand or gets on activation.
type InstallOptions ¶
type InstallOptions struct {
// Dev points the install at the folder instead of copying it.
Dev bool
// HostVersion is this harnessly's version, checked against the manifest's range.
HostVersion string
Now func() time.Time
}
InstallOptions say how to install.
type Installed ¶
type Installed struct {
ID string `json:"id"`
Version string `json:"version"`
// Dir is the package's folder: the copy, or the author's folder for a dev install.
Dir string `json:"dir"`
// Source is the folder or address it was installed from.
Source string `json:"source"`
Dev bool `json:"dev,omitempty"`
InstalledAt int64 `json:"installedAt"`
UpdatedAt int64 `json:"updatedAt"`
// Manifest is the manifest as installed, so the list needs no read of every package.
Manifest *Manifest `json:"manifest"`
}
Installed is one installed app as the registry keeps it.
type Launcher ¶
type Launcher struct {
Registry *Registry
// GuardCommand is the hook command line; "" is `harnessly hook app-guard` off the agents' PATH.
GuardCommand string
}
Launcher is agents.AppLauncher over a registry.
type MCPServer ¶
type MCPServer struct {
Type string `json:"type,omitempty"`
URL string `json:"url,omitempty"`
Command string `json:"command,omitempty"`
Args []string `json:"args,omitempty"`
Env map[string]string `json:"env,omitempty"`
Headers map[string]string `json:"headers,omitempty"`
}
MCPServer is one server of .mcp.json: a remote one (url) or, for a trusted app, a local process (command).
type Manifest ¶
type Manifest struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
Icon string `json:"icon,omitempty"`
Version string `json:"version"`
Harnessly string `json:"harnessly"`
Trust string `json:"trust"`
Targets []string `json:"targets"`
When string `json:"when,omitempty"`
Activation *Activation `json:"activation,omitempty"`
Permissions []string `json:"permissions"`
Network *Network `json:"network,omitempty"`
Secrets []Secret `json:"secrets,omitempty"`
Settings json.RawMessage `json:"settings,omitempty"`
Agent *Agent `json:"agent,omitempty"`
Views []View `json:"views,omitempty"`
Chat *Chat `json:"chat,omitempty"`
Sinopia json.RawMessage `json:"sinopia,omitempty"`
Storage json.RawMessage `json:"storage,omitempty"`
Backend *Backend `json:"backend,omitempty"`
}
Manifest is harnessly/app.json.
type Network ¶
type Network struct {
Connect []string `json:"connect,omitempty"`
Resources []string `json:"resources,omitempty"`
Frames []string `json:"frames,omitempty"`
Reason string `json:"reason,omitempty"`
}
Network lists the hosts a view may reach; "*" needs a reason.
type Package ¶
type Package struct {
Dir string
Manifest *Manifest
// MCP is the package's .mcp.json servers by name, as written.
MCP map[string]MCPServer
}
Package is a package read from a folder.
type Problem ¶
type Problem struct {
Path string `json:"path"`
Message string `json:"message"`
// Warning problems do not stop an install; --strict counts them as errors.
Warning bool `json:"warning,omitempty"`
}
Problem is one thing wrong with a package: the field it is about and what is wrong, in words.
type Problems ¶
type Problems []Problem
Problems is the list a check returns; empty means the package is fine.
type Range ¶
type Range [][]comparator
Range is a parsed harnessly field.
func ParseRange ¶
ParseRange reads a range; the error says what is wrong in words.
type Registry ¶
type Registry struct {
Root string
// contains filtered or unexported fields
}
Registry reads and writes the list; every writer of this process goes through one Registry.
func (*Registry) Install ¶
Install checks the package in dir and installs it, replacing an installed version of the same app. The problems are all the check found (warnings included); an install with errors is refused with ErrInvalid.
type Secret ¶
type Secret struct {
Name string `json:"name"`
Description string `json:"description"`
Optional bool `json:"optional,omitempty"`
}
Secret is a secret the app asks for at install; the person types its value, the app never reads it.
type Snapshot ¶
type Snapshot struct {
Apps []SnapshotApp `json:"apps"`
Protected []string `json:"protected"`
}
Snapshot is the tool policy a chat's launch was given: its apps' rules as they were at the launch, and the folders the agent must not write (the registry and the apps' packages), so editing a manifest or turning an app off from inside the chat does not loosen the rules of the agent that runs. The launch writes it next to its settings and the guard reads it there: the hook decides alone, with nothing to wait for.
type SnapshotApp ¶
type SnapshotApp struct {
ID string `json:"id"`
Name string `json:"name"`
Tools *ToolPolicy `json:"tools,omitempty"`
}
SnapshotApp is one app of a snapshot.
type ToolPolicy ¶
type ToolPolicy struct {
Allow []string `json:"allow,omitempty"`
Deny []string `json:"deny,omitempty"`
Confirm []string `json:"confirm,omitempty"`
}
ToolPolicy is checked deny → confirm → allow.