apps

package
v0.16.42 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2026 License: Apache-2.0 Imports: 17 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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.

View Source
const (
	TargetChat = "chat"
	TargetPane = "pane"
	TargetApp  = "app"
)

Targets an app works in. sinopia.<kind> names one Sinopia document type, sinopia.* all of them.

View Source
const (
	OnManual   = "manual"
	OnView     = "view"
	OnDocument = "document"
	OnAlways   = "always"
)

Activations: how an app turns on.

View Source
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
)
View Source
const FirstVersion = "0.16.36"

FirstVersion is the first host version with apps: the range a new package starts with.

View Source
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.

View Source
const ManifestPath = "harnessly/app.json"

ManifestPath is where the manifest lives inside a package.

Variables

View Source
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")
)
View Source
var Templates = []string{"chat", "pane-chat"}

Templates are the starting points of `harnessly app new --template`.

Functions

func CompareVersions

func CompareVersions(a, b string) int

CompareVersions orders two app versions (1.2.0 < 1.10.0); a version that does not parse sorts first.

func LoadPackage

func LoadPackage(dir string) (*Package, Problems)

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

func ParseManifest(raw []byte) (*Manifest, Problems)

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

func PluginName(id string) string

PluginName is the Claude Code plugin name of an app: its skills are <plugin>:<skill> to the agent.

func Scaffold

func Scaffold(dir, id, name, template string) error

Scaffold writes a new package for id into dir, which must not exist or be empty.

func SnapshotIntact

func SnapshotIntact(path string, body []byte) bool

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 Backend

type Backend struct {
	URL string `json:"url"`
}

Backend is the app's own server.

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 Decision

type Decision string

Decision is the guard's answer for one call.

const (
	// DecideNone: no app has a rule for the call; the chat's own permissions decide.
	DecideNone    Decision = ""
	DecideAllow   Decision = "allow"
	DecideConfirm Decision = "confirm"
	DecideDeny    Decision = "deny"
)

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.

func (*Launcher) Claude

func (l *Launcher) Claude(ids []string, settingsPath string) (agents.ClaudeApps, error)

Claude is what a Claude Code chat with the apps adds to its launch.

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.

func (*Manifest) Check

func (m *Manifest) Check() Problems

Check is every rule of the manifest on its own, without the package's files (Package.Check adds those).

func (*Manifest) HasTarget

func (m *Manifest) HasTarget(target string) bool

HasTarget says whether the app works in a target; sinopia.* covers every Sinopia kind.

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.

func (*Package) File

func (p *Package) File(rel string) ([]byte, error)

File reads a file of the package by a manifest path.

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.

func (Problem) String

func (p Problem) String() string

type Problems

type Problems []Problem

Problems is the list a check returns; empty means the package is fine.

func (Problems) Error

func (ps Problems) Error() string

func (Problems) Errors

func (ps Problems) Errors() Problems

Errors are the problems that are not warnings.

type Range

type Range [][]comparator

Range is a parsed harnessly field.

func ParseRange

func ParseRange(s string) (Range, error)

ParseRange reads a range; the error says what is wrong in words.

func (Range) Allows

func (r Range) Allows(version string) bool

Allows says whether the host version is in the range. A host built from source ("dev") is in every range.

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 Open

func Open(dataDir string) *Registry

Open is the process's one Registry of a data folder.

func (*Registry) Get

func (r *Registry) Get(id string) (Installed, error)

Get is one installed app.

func (*Registry) Install

func (r *Registry) Install(dir string, opt InstallOptions) (Installed, Problems, error)

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.

func (*Registry) List

func (r *Registry) List() ([]Installed, error)

List is every installed app, by id.

func (*Registry) Remove

func (r *Registry) Remove(id string) error

Remove uninstalls an app and deletes its copy; the author's folder of a dev install is left as it is.

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.

func (Snapshot) Decide

func (s Snapshot) Decide(call Call) (Verdict, string)

Decide is the snapshot's verdict for one call, with the reason the agent reads.

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.

type Verdict

type Verdict struct {
	Decision Decision
	App      string
	Rule     string
}

Verdict is the decision with the app and the rule that made it, for the reason the agent reads.

func Decide

func Decide(apps []*Manifest, call Call) Verdict

Decide is the verdict of the apps on in a chat for one call.

func (Verdict) Reason

func (v Verdict) Reason(appName string) string

Reason is the verdict in words for the agent.

type View

type View struct {
	ID      string   `json:"id"`
	Title   string   `json:"title,omitempty"`
	Entry   string   `json:"entry"`
	Targets []string `json:"targets"`
	Height  string   `json:"height,omitempty"`
}

View is a page of the app: a tab, a full screen, a card in the chat or a Sinopia panel.

Jump to

Keyboard shortcuts

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