Skip to content

hyabundle Specification

hyabundle (.hyabundle archive format) is Hya’s unified, deterministic extension package format. Conceptually aligned with the Claude Code Plugin ecosystem, a single bundle can package any combination of:

  • Tools — model-callable tools exposed through Hya’s tool plane;
  • Hooks — lifecycle interceptors and observers across Hya’s 20 standard hook points;
  • MCP Servers — bundle-local stdio MCP servers or external http / sse MCP endpoints;
  • Agents — custom main or subagent roles with system prompts, model policies, and scoped resource views;
  • Skills & Commands — on-demand SKILL.md guides and /command slash-command templates;
  • Advanced extensions — compiled *.hya.md Workflows, vertical channel policies, custom URI schemas:, custom HTTP/gRPC apis:, custom permission_modes:, and sandboxed @hya/tui-sdk TUI panels.

For a step-by-step developing, installing, and publishing walkthrough, see Developing, Installing & Publishing Bundles (.hyabundle). For the native Rust cdylib contract, see Native Bundle Runtime ABI v2.


1. Runtime Archetypes & Core Invariants

1.1 Three Bundle Archetypes

hyabundle (schema_version: 2) converges on two executable runtimes plus a declarative static form (and allows hybrid native + tui bundles that pair a Rust cdylib with a @hya/tui-sdk v2 UI extension):

Archetype runtime.kind Execution model Primary use cases Isolation & trust model
Static Bundle static (default) No executable code; declarative manifests and assets only Agents, Skills, Commands, Workflows, Channel policies, remote/local MCP config, standalone TUI bundles Zero extra processes, zero native library overhead
JS Bundle js Out-of-process JS/TS interpreter (Bun) speaking stdio NDJSON JSON-RPC 2.0 (Plugin Protocol v1); natively compatible with Claude Code Plugins Ecosystem & user plugins: custom tools, hooks, model routers, HTTP APIs, permission modes, TUI extensions, imported Claude plugins Separate OS subprocess; crashes or timeouts cannot destabilize the Hya host
Native Bundle native Pure Rust crate compiled to a dynamic library (.so / .dylib / .dll), loaded via dlopen against Lockstep Native ABI v2 (crates/hya-runtime-abi) High-performance built-in capabilities (any subset on top of hya --bare), kernel-level Rewriter extensions, managed services, drivers, and BundleApi handlers In-process dynamic library; verified against 32-byte SHA-256 ABI v2 digest and mediated exclusively through Arc<dyn HostRuntime>

1.2 Core Invariants

  1. Declaration separated from implementation: Regardless of runtime (js, native, or static), every exported tool, hook, MCP server, agent, skill, and slash command is declared via standardized descriptor files. Hya can statically validate schemas, index catalogs, display permission postures, register MCP endpoints, and clamp agent tool views without spawning a process or loading a dynamic library.
  2. Minimal hya --bare bootability: hya --bare, hya server run --bare, and hya exec --bare run without installed or project bundles and must always boot and run with the 8 standard bare tools (read, write, edit, bash, grep, todo, rewrite, skill). Installed bundles add their capabilities on top of that set, and any subset works (bundles.builtin in config.toml; prerequisites in requires:).
  3. Packaged artifact separated from source tree: Source directories may hold tests (*.test.ts), Rust source trees (native/src/), and READMEs. Packaging into .hyabundle includes only the declared closure and target runtime artifacts (JS entrypoints or compiled platform dynamic libraries), ensuring compact, deterministic, and optionally closed-source distribution.
  4. Portable, independent CI: Bundle verification does not depend on Hya’s main workspace test suite, hya-e2e, or TUI suites. The official extras and examples are packaged from the Hya bundles repository.

2. Bundle repositories and distribution

Bundle source, build jobs, and releases live in the publisher’s repository. chrono-foundry/hya-bundles publishes the official bundles and examples. The official registry’s default profile includes 17 native, three static, and one standalone TUI bundle. Tools, agents, and bundles lists the profile’s features.

Publish each bundle with its own SemVer identity. Users install packages from a registry or a local archive. The registry protocol defines artifact selection and Sigstore trust verification.


3. Source Directory Layout & Manifest Schema

3.1 Standard Source Directory Layout

All subdirectories are optional; include only the capabilities your bundle provides:

<bundle-name>/
├── bundle.yaml # Required manifest (or bundle.hya.md for single-agent bundles; mutually exclusive)
├── README.md # Optional human documentation (not required in runtime closure)
├── config.example.yml # Optional example settings in YAML (never embed secrets)
├── tools/ # Tool descriptor files (*.json / *.yaml)
│ └── <tool-id>.json
├── hooks/ # Hook descriptor files (*.json / *.yaml)
│ └── hooks.json # or split per hook: <hook-id>.json
├── mcp/ # MCP server descriptor files (*.json)
│ └── <server-id>.json
├── agents/ # Agent definitions (*.md frontmatter, or prompts/*.md)
│ └── <agent-id>.md
├── skills/ # Skill guides (one directory per skill)
│ └── <skill-id>/SKILL.md
├── commands/ # Slash command templates (*.md or commands.yaml)
│ └── <command-id>.md
├── workflows/ # Workflow sources, declared under `assets:` (workflows/<id>.hya.md)
│ └── <workflow-id>.hya.md
├── schemas/ # JSON Schemas for custom HTTP/gRPC APIs
│ └── <schema>.json
├── tui/ # TUI extension (@hya/tui-sdk)
│ └── main.ts
├── src/ # [JS Bundle] TypeScript/JavaScript source & unit tests
│ ├── index.ts # Entrypoint (pre-bundle to self-contained file if importing helpers)
│ └── index.test.ts # Executed by check.command; excluded from .hyabundle archive
└── native/ # [Native Bundle] Standalone Rust crate (crate-type = ["cdylib"])
├── Cargo.toml
└── src/
└── lib.rs

3.2 bundle.yaml Manifest Schema

Manifest parsing enforces strict unknown-field rejection (deny_unknown_fields) so typos fail immediately during validation or packaging.

kind: Bundle
schema_version: 2 # Required: v2 only (migrate v1 manifests via `hya-migration run`)
identity:
id: acme/my-bundle # Required: <publisher>/<name>
version: 1.0.0 # Required: independent bundle SemVer
publisher: acme # Required: publisher identifier
namespace: my-bundle # Optional: defaults to <name>; reserved: mcp, harness, builtin, plugin
overrides: hya/bare # Optional: declare bundle-level override of another bundle (e.g. hya/bare)
requires: [hya/agent-channels] # Optional: bundles that must be enabled with this one (see "Prerequisites and default agent")
default_agent: my-lead # Optional: this bundle's `role: main` Agent that becomes the default primary agent
tool_plane: internal_public # Optional: internal_public (default) | full (requires verified official provenance)
# Unified runtime declaration: static (default) | js | native
runtime:
kind: js # static | js | native
# --- when kind: js ---
mode: managed # managed (hya-plugin-bun) | process (standalone JSON-RPC) | claude
entry: src/index.ts # managed mode entrypoint (self-contained JS/TS)
command: [bun, run, "${BUNDLE_ROOT}/src/index.ts"] # process mode argv
timeout_ms: 30000 # Optional: 1000..=3600000
# --- when kind: native ---
abi_version: 2 # Required: 2 (Lockstep Native ABI v2 via crates/hya-runtime-abi)
crate_dir: native # Source build directory (not packed as source files into .hyabundle)
library: native/libacme_my_bundle.so # Target dynamic library path inside packaged .hyabundle
capabilities: [tools, hooks, rewriters, services, apis, schemas, drivers, providers]
# Self-check contract executed by CI and `hya bundle verify`
# Tip: use `--pass-with-no-tests` with `bun test` so stripped `.hyabundle` archives (which omit `*.test.ts`) still verify cleanly.
check:
command: [bun, test, --pass-with-no-tests] # Direct argv (no shell interpolation)
timeout_secs: 120 # 1..=600
# Standardized resource descriptor index
resources:
tools:
- id: my_tool
path: tools/my_tool.json
aliases: [mt] # Optional local aliases (never `todo` or `rewrite`)
overrides: hya/bare # Optional: per-tool override target (e.g. hya/bare or hya/multi-agent)
hooks:
- id: tool.execute.before
path: hooks/hooks.json
mcp:
- id: local-search
path: mcp/local-search.json
skills:
- id: my-guide
path: skills/my-guide/SKILL.md
commands: # First-class slash command resources
- id: review
path: commands/review.md
# Agent definitions: standalone Markdown files (Claude Plugin compatible) or inline entries
agents:
- path: agents/my-agent.md
# Inline form also supported:
# - id: my-agent
# role: subagent # main | subagent
# description: ...
# prompt: prompts/my-agent.md
# model_policy: { category: quick, reasoning: low }
# resource_view: { allow: [...], deny: [...], aliases: {...} }
# advertise: [...]
# can_spawn: [...] # Agent ids, or ["*"] for every non-private agent
# private: false
# handoff: model # model | deterministic
# hook_refs: [tool.execute.before]
# Advanced capabilities
schemas: [] # Custom URI schemes (e.g. db:// -> bundle tool, or native UriSchemaHandler)
apis: [] # Custom HTTP/gRPC endpoints (JS process mode OR Native ABI v2 NativeBundleApiHandler)
permission_modes: [] # Custom permission modes paired with hook/permission.approve
cli: [] # `hya` commands this bundle contributes (see "CLI commands" below)
tui: # Sandboxed TUI extension (@hya/tui-sdk v2; may be combined with runtime.kind: native)
api_version: 2
entry: tui/main.ts
sdk: "2.0.0"
permissions: []
# Runtime data assets only (JSON schemas, templates, TUI sources, Workflow
# sources, config skeletons). Native bundles do NOT list native/src/*.rs files here.
assets:
- id: usage-schema
path: schemas/usage.json
- id: my-flow # A Workflow source: id = its `name`, path = workflows/<id>.hya.md
path: workflows/my-flow.hya.md

Channel templates (channels/<id>.yaml assets)

Channel templates are ordinary assets at channels/<id>.yaml, declared under assets: like any other data file. hya/agent-channels reads them: its own templates when it registers, and the templates of the other bundles in a catalog when it compiles that scope’s channel policy; it owns their schema and validation. Preparation checks only their paths and digests. A top-level channels: manifest key is rejected by name, with a message that points to channels/<id>.yaml assets.

Workflow sources are ordinary assets: hya bundle install and preparation check only their paths and digests and never compile them. The hya/workflow bundle compiles them when it builds its catalog. A source whose name differs from its asset id, whose path is not workflows/<id>.hya.md, that does not compile, or whose stages (or the Agents they can spawn) name an Agent the same bundle does not define shows as an INVALID: row in hya workflow list and is refused by info, use, and run; the bundle’s other Workflows stay usable. The workflow: manifest key of earlier releases is an unknown field now.

Strict schema_version: 2 Enforcement

Hya v2 accepts schema_version: 2 manifests exclusively. Legacy v1 manifests (extensions.* blocks, omitted schema_version, or legacy exposure policy files) are rejected at parse time; run hya-migration run to upgrade existing v1 user or project bundles (see Migrating from Hya v1 to v2). Native bundles are never required to list native/src/*.rs files under assets:.

CLI commands (cli:)

A bundle can add commands to the hya command line at arbitrary positions — either at the top level or mounted under any existing namespace command via parent: [...]. When the bundle is enabled, hya --help (or the parent namespace’s --help) lists them prefixed with [from: <vendor/name>], and hya [parent...] <name> … runs them; when it is disabled (or with --bare for built-in bundles, or --pure for user-installed bundles) they do not exist. An enabled user-installed bundle with the same ID as a non-preset first-party bundle (or declaring overrides: / the same namespace) shadows that first-party bundle across CLI, runtime, and providers—even if the replacement omits cli:, the shadowed first-party CLI entry is suppressed. Each command routes to one of the bundle’s own extension points:

  • driver: <name> runs the bundle’s native driver <bundle-id>:<name> in a headless in-memory session. The driver receives the parsed arguments as DriverRequest::args and returns a DriverReport (stdout, stderr, exit_code), which hya prints and exits with. Only runtime.kind: native bundles have drivers.
  • api: <endpoint-id> calls one of the bundle’s BundleApi endpoints with the JSON body {"args": {…}, "cwd": "<absolute working directory of the caller>"}; the reply body must be {"stdout": …, "stderr": …, "exit_code": …}, which hya prints (stdout, then stderr) and exits with when exit_code is nonzero. A failure the bundle detects is such a reply (for example stderr: "Error: <message>\n", exit_code: 1); a missing endpoint, a non-2xx status, or a body of another shape is reported by hya itself (Error: …, exit 1). A Session-scope endpoint runs for a new session in the caller’s directory; a Global endpoint gets no session. This works for JS (apis:) and native (NativeBundleApiHandler) bundles alike.

By default an api route runs on a headless in-memory store. With database: true it runs against --db instead, under the same database lock as hya exec (see CLI reference: Database lock & exit codes):

  • When no live server holds the database, hya claims it, runs the call in process, and drains the store on exit. A command with a value: session argument given claims strictly; without one, an open timeout or storage fault falls back to an in-memory store, as hya exec does.
  • When a server owns the database, the call goes to it over /v2 (/v2/sessions/{session}/bundles/{bundle}/… or /v2/bundles/{bundle}/api/…) with no client request timeout, so a long call is not cut off; permission asks and questions of the call’s session tree are rejected while it runs. A Session-scope endpoint without a session argument gets a new session on the server (with --model/--effort).
  • A value: session argument names an existing Session: a Session-scope endpoint runs for it instead of a new one (Error: <command> Session `<id>` was not found when it does not exist). It stays in args as the typed string.
  • routed_refuse lists what the owning server cannot take, in order. When the call would be routed and an entry’s arg is given (a flag set, a string or integer present, a list non-empty) or its global flag (pure, yolo) is set, hya prints hya <command>: database <db> is in use by hya server pid <pid> at <url>, and <reason>; stop it (`hya server stop --db <db>`) or pass another --db and exits 75 before creating any session. In process the entries do not apply.

With database: read the route only reads --db: hya never claims it or goes through its server, so the command works while either holds it. When --db names an existing file, hya opens it read-only to find the Project of the working directory (defaulting to the working directory alone). For native ABI v2 bundles, hya invokes the bundle’s Global NativeBundleApiHandler directly with a lightweight read-only HostCatalogReader—without starting the SessionEngine, native services, provider libraries, or Code Mode—while honoring config.toml bundles.builtin and writing no config file. A Global endpoint sees the Project’s roots through resolve_scope_catalog(None, Some(cwd)), whose diagnostics list the installed bundles that could not be read (installed bundle <id>: <error>) and the project bundles that failed to load (project bundle <dir>: <error>). hya workflow list|info (hya/workflow) prints them as warning: lines.

cli:
- name: notes
subcommands:
- name: show
api: show # a Session-scope endpoint
database: true
args:
- { id: session, long: session, value: session }
- { id: revision, long: revision }
routed_refuse:
- { arg: revision, reason: "`notes show --revision` cannot be sent to it" }
- { flag: yolo, reason: "--yolo cannot apply to it" }
- parent: [session] # mounts `hya session summarize` under core `session` namespace
name: summarize
about: Summarize a persisted session.
api: summarize
database: read

Every bundle CLI command displays [from: <vendor/name>] at the beginning of its --help description (both in its parent command’s subcommand listing and in its own --help header), so users can always distinguish bundle-provided commands from core hya commands.

cli:
- name: echo # hya echo … ([a-z][a-z0-9-]*, never shadows core commands)
about: Print text through the bundle's driver.
driver: echo # or `api: <endpoint-id>`
args:
- id: text # key in the JSON arguments
long: text # --text; omit long/short for a positional argument
required: true
help: Text to print.
- id: times
long: times
value: integer # string (default) | integer | flag | list
default: "1"
- { id: loud, long: loud, value: flag, conflicts_with: [quiet] }
- { id: quiet, long: quiet, value: flag }
- { id: tag, long: tag, value: list, aliases: [label], value_name: TAG }
- name: group # a pure namespace command has no route or `args`
subcommands:
- { name: list, api: list }
- parent: [session] # arbitrary-position mounting under an existing namespace
name: export-md
about: Export a session transcript to Markdown.
api: export_md
database: read
Field Type Meaning
parent list of string (optional, top-level only) Existing namespace command path to mount under (e.g. [session] mounts hya session <name>, [group] mounts under another bundle’s namespace). Omit or leave empty to mount at the top level (hya <name>).
name string (required) Subcommand name ([a-z][a-z0-9-]*, never help).
about string Help text (automatically prefixed with [from: <vendor/name>] at runtime).
driver / api string The route of a leaf command (exactly one).
database false (default) | true | read true: run the api route against --db (in process or through the owning server) instead of an in-memory store; read: read --db without claiming it (see above).
routed_refuse[] list database: true only: {arg: <argument id>, reason} or {flag: pure|yolo, reason}; the first set entry exits 75 when the call would be routed.
args[] list id, long, short, value (string, integer (u32), flag, list, session), required, default, help, value_name, aliases, conflicts_with (argument ids). Missing optional values are null in the JSON arguments; a flag is true/false; a list is an array; a session is the typed Session id string (at most one, database: true only). Forbidden on namespace commands (commands with subcommands).
subcommands[] list Nested commands with the same shape (parent is only permitted on top-level cli: entries).

Anti-shadowing & anti-masking guarantees:

  • Manifest preparation rejects an invalid name or parent segment (including help), parent on nested subcommands, args on a namespace command, a leaf without exactly one route, a driver route on a non-native bundle, an api route to an undeclared endpoint of a JS bundle, duplicate (parent, name) entries or flags, reserved core flags (--help, --version, --model, --effort, --yolo, --bare, --bundles, --pure, --db, -h, -V, -m), conflicts_with naming an unknown argument, database on a driver route, value: session or routed_refuse without database: true, more than one value: session argument, and malformed routed_refuse entries.
  • CLI assembly at startup mounts contributions shallowest-parent-first and rejects: (1) any command colliding with a core command or alias at its mount point, (2) any command colliding with another enabled bundle’s command at the same path, (3) any parent path that does not exist, and (4) any attempt to mount under a leaf action command (only pure namespace commands that accept subcommands may be extended).

A user-installed native bundle (runtime.library) contributes commands the same way, when enabled by the runtime selection; bundles/examples/cli-driver-example routes one command to a driver, one to a native Global BundleApi endpoint, and two database: true commands to a Global and a Session-scope endpoint.

Prerequisites and default agent (requires:, default_agent:, can_spawn: ["*"])

A bundle names the bundles it cannot work without in requires:, and may make one of its Agents the default primary agent with default_agent:.

requires: [hya/agent-channels] # bundle ids (<publisher>/<name>)
default_agent: my-lead
agents:
- id: my-lead
role: main
can_spawn: ["*"] # may spawn every non-private agent of the catalog
Field Type Meaning
requires list of <publisher>/<name> Bundles that must be enabled with this one. A requirement is met by a bundle with that id or by a bundle that overrides it. Preparation sorts the list and removes duplicates.
default_agent Agent id This bundle’s Agent that becomes the default primary agent while the bundle is enabled.
agents[].can_spawn list of Agent ids, or ["*"] "*" grants spawning every non-private agent in the catalog, including agents installed later.

Preparation rejects a requires entry that is not a <publisher>/<name> id or names the bundle itself; a default_agent that does not name a non-private role: main Agent of the same bundle; and "*" combined with other can_spawn entries. When the enabled set misses a prerequisite, a built-in bundle fails startup with a message naming the missing bundle, and an installed or project bundle is left out with a warning; nothing is enabled implicitly. At most one enabled bundle may declare default_agent; with none, the core’s hya-bare agent is the default.

Prepared bundles carry both fields only when they are declared, so the digest of a bundle that uses neither does not change.


4. Standardized Descriptor File Schemas

Both JS Bundles and Native Bundles use the exact same five descriptor schemas so static validation, catalog indexing, and permission inspection are identical across runtimes.

4.1 Tool Descriptor (tools/<id>.json or tools/tools.yaml)

{
"schema_version": 1,
"name": "webfetch",
"description": "Fetch a web page and extract readable content.",
"permission": "tool",
"aliases": [
{ "name": "fetch", "visibility": "hidden" }
],
"prompt_hint": "fetch a web page",
"protected": false,
"parameters": {
"type": "object",
"properties": {
"url": { "type": "string", "description": "Target HTTP(S) URL" }
},
"required": ["url"]
},
"entrypoint": {
"js": "src/index.ts#webfetch",
"native": "webfetch"
}
}
  • permission: read_only | tool | command | interactive.
  • view (optional): how agent views receive the tool, whatever their resource_view.allow selects.
    • inject: always adds the tool to every agent view whose tool plane offers it; spawn_rights adds it only for agents that may spawn someone (non-empty can_spawn), and agents without spawn rights never see it, not even through allow. A view that already gives the tool’s bare name to one of its own resources or aliases keeps that resource.
    • undeniable: true: a resource_view.deny naming the tool fails bundle loading.
    • Example: hya/multi-agent’s report declares "view": { "inject": "always", "undeniable": true }; hya/multi-agent’s task declares "view": { "inject": "spawn_rights" }.
  • file_operations_rule (optional string, native tools): replaces the kernel prompt’s rule that sends file operations to bash in any round that offers this tool. hya/coding-extras declares "Use the file tools, not shell commands, to list, find, and search files" on ls, glob, and find.
  • entrypoint:
    • JS (managed): <module-path>#<exported-tool-name>.
    • JS (process): tool name dispatched via JSON-RPC tool/call.
    • Native: matches Tool::name() registered into NativeRegistrations::tools by hya_native_register_v2; mismatches fail bundle loading.
  • Names & overrides: A native tool registers under its own name (Tool::name()), whatever the bundle’s publisher. When two enabled bundles export the same name, exactly one of them must declare overrides: <other-bundle-id> (overrides: hya/bare to replace a standard tool, as hya/hashline does for read, write, edit, and grep); otherwise the load fails, and load order never decides. Only tools served by a bundle’s JS runtime (managed or process) and plugin tools are qualified, as namespace__local (the namespace must not be mcp, harness, or builtin), and MCP tools are mcp__<server>__<local>. rewrite and todo remain permanently reserved for hya-core.

4.2 Hook Descriptor (hooks/hooks.json or hooks/<id>.json)

Aligned with Claude Code’s hooks/hooks.json semantics:

{
"schema_version": 1,
"hooks": [
{
"event": "tool.execute.before",
"matcher": "^bash$",
"handler": {
"kind": "js",
"target": "src/index.ts#guardBash"
},
"failure_mode": "fail_closed",
"timeout_ms": 5000
},
{
"event": "model.fallback",
"handler": {
"kind": "rpc",
"method": "hook/model.fallback"
},
"timeout_ms": 10000
}
]
}

The 15 Core Hook Events

Category Hook events
Tools & Permissions (5) tool.execute.before (always fail-closed), tool.execute.after, tool.visibility, permission.ask, permission.approve
Requests & Routing (4) chat.params, model.fallback, message.user.before, command.execute.before
Text & Context (3) experimental.text.complete, compaction.before, compaction.after
Lifecycle Observation (3) session.start, session.end, event

A hook may also implement a bundle-declared hook point, named <bundle-id>:<point> (for example hya/goal:evaluate or hya/loop:verifier). The declaring bundle registers the local point name in NativeRegistrations::hook_points, owns the JSON payload shapes, and dispatches the point through HostExtensionRegistry::invoke_hook. The first implementer that answers wins (null defers), and a failing implementer is skipped. A JSON-RPC process registers the full name in hooks: and receives hook/<bundle-id>:<point>. The core hook names of earlier releases for these points (goal.evaluate, loop.verifier, loop.planner, and loop.should_stop) are no longer accepted; use hya/goal:evaluate, hya/loop:verifier, hya/loop:planner, and hya/loop:should_stop.

handler.kind Targets

handler.kind Dispatch mechanism
js Exported function loaded by hya-plugin-bun (<path>#<export>)
rpc Standalone JSON-RPC 2.0 process method (hook/<event>)
command Shell command hook executed by hya-plugin-claude (Claude Code compatibility)
native Native dynamic-library hook handler registered via ABI v2 (hya_native_register_v2 / NativeRegistrations::hooks)

4.3 MCP Server Descriptor (mcp/<server-id>.json)

Supports both bundle-local stdio servers and remote http / sse servers (compatible with .mcp.json):

{
"transport": "stdio",
"command": ["bun", "run", "${BUNDLE_ROOT}/mcp/server.ts"],
"env": {
"CONFIG_PATH": "${BUNDLE_CONFIG_FILE}"
},
"timeout_ms": 600000,
"enabled": true
}
{
"transport": "http",
"url": "https://mcp.example.com/v1",
"headers": {
"Authorization": "Bearer ${env:EXAMPLE_API_TOKEN}"
},
"timeout_ms": 30000,
"enabled": true
}
  • Validation rules: Exactly one of command or url must be set (mutually exclusive). Path expansion only permits allowlisted placeholders (${BUNDLE_ROOT}, ${BUNDLE_CONFIG_FILE}, ${BUNDLE_CONFIG_DIR}) and ${env:VAR} references; hardcoded secrets fail strict validation.
  • Tool plane naming: Discovered MCP tools register as mcp__<server_id>__<tool_name> and pass through ProjectScope and permission approval.

4.4 Agent Descriptor (agents/<agent-id>.md)

Supports standalone Markdown files with YAML frontmatter (matching Claude Code Plugin agents/*.md) alongside inline bundle.yaml#agents:

---
id: scout
role: subagent # main | subagent
description: Fast read-only retrieval scout.
color: cyan # Optional UI hint color
model_policy:
category: quick # Optional: quick | deep | ...
reasoning: low # Optional: low | medium | high
handoff: deterministic # model (default) | deterministic
private: false # true = internal to workflows or explicit callers
can_spawn: [] # Allowed child agent IDs, or ["*"] for every non-private agent
advertise: [] # Optional subset of tools advertised to the model
hook_refs: [] # Local hook IDs from this bundle only
resource_view:
allow:
- harness:tool/read
- harness:tool/grep
- harness:tool/glob
- zvec-grep # Bundle-local resource ID
deny: []
---
You are a read-only codebase scout. Return concise findings with `path:line` evidence.

resource_view.allow and advertise entries must name a resource the agent’s plane holds when the view is built; a missing one fails the agent. A resource_view.deny entry harness:tool/<id> that no Harness tool answers is satisfied as is when a known bundle declares <id> under resources.tools (a bundle-local tool of the same name does not count as a Harness tool). Known bundles are every first-party manifest, every installed bundle whether enabled or not, and every bundle in the bound scope’s catalog. The agent’s own bundle is one of them, so a harness: deny of a tool its own bundle declares is satisfied as is, also when that bundle’s library registered nothing. So a deny never requires the bundle that registers its tool: hya-scout denies harness:tool/apply_patch and resolves with hya/coding-extras disabled. Any other deny that names nothing still fails: a misspelt or wrong-case tool name, an absent skill or MCP server, a present resource named by an alias or under the wrong kind, or a malformed reference.

4.5 Skill & Command Descriptors

  • Skill (skills/<skill-id>/SKILL.md): YAML frontmatter (name, description) plus Markdown body; maximum 256 KiB per file.
  • Command (commands/<command-id>.md): YAML frontmatter (name, description, hints, subtask) plus prompt template body supporting $ARGUMENTS expansion.

5. Runtime Wire & ABI Contracts

5.1 JS Bundle: stdio NDJSON JSON-RPC 2.0 (Plugin Protocol v1)

  • Framing: One UTF-8 JSON object per line (max 1 MiB per frame). stdin and stdout carry protocol frames exclusively; diagnostic logs must write to stderr.
  • Environment injection: The host injects HYA_BUNDLE_ROOT (materialized bundle directory), HYA_BUNDLE_CONFIG_FILE (resolved user bundle settings in TOML), and HYA_BUNDLE_CONFIG_DIR.
  • Host → Plugin methods:
    • initialize (5 s timeout) — negotiates protocol_version: 1, receives plugin metadata, and verifies that declared tools, hooks, and apis match the manifest descriptors;
    • shutdown — requests clean process termination (exit 0);
    • event — one-way notification;
    • tool/call, api/request, hook/<event> — request/response invocations.
  • Plugin → Host method:
    • host/capability — authenticated with an invocation-scoped capability token; supports context.describe, session.usage, workspace.state, permission.assert, tools.list, and tool.call.

See Sidecar Plugins, Custom Tools & Hooks for full JSON-RPC payload examples.

Claude Code Plugin Compatibility Mapping (hya-plugin-claude)

hya bundle install --claude <dir | marketplace#entry> translates Claude Code plugins into deterministic .hyabundle packages:

Claude Code Plugin artifact hyabundle target
plugin.json / .claude-plugin/plugin.json identity.id: claude/<name>
agents/*.md agents/
skills/*/SKILL.md resources.skills
commands/*.md resources.commands
.mcp.json resources.mcp
hooks/hooks.json PreToolUse → tool.execute.before, PostToolUse → tool.execute.after, PreCompact → compaction.before, SessionStart → session.start, SessionEnd → session.end, SubagentStart → hya/multi-agent:spawn (unsupported events fail import explicitly)

5.2 Native Bundle: Lockstep Native ABI v2 (crates/hya-runtime-abi)

Official native bundles target Lockstep Native ABI v2 (runtime.abi_version: 2), implemented in crates/hya-runtime-abi (exported via export_native_bundle_v2!) and loaded by crates/hya-tool-loader through the one path every native bundle takes, first-party or installed (load_native_bundle). Native ABI v2 crates MUST NOT link hya-store, sqlx, hya-engine, hya-server, axum, or tonic; instead, the host injects an Arc<dyn HostRuntime> into NativePluginContext.

Exported C symbol Required Purpose
hya_native_abi_v2(out: *mut u8) Yes Writes a 32-byte SHA-256 ABI v2 digest verified before registration. Mismatches fail cleanly with AbiError::DigestMismatch.
hya_native_with_runtime_v2(handle, callback, state) Yes Polls async futures synchronously inside the bundle’s Tokio runtime context.
hya_native_share_deadline_v2(cell: *const c_void) Yes Shares the host’s process-lifetime deadline cell with the dynamic library.
hya_native_register_v2(ctx, regs, error_out) -> i32 Yes Populates NativeRegistrations (tools, rewriters, services, hooks, api_handlers, projection_reducers, uri_schema_handlers, hook_points, drivers, providers) via export_native_bundle_v2!.

For the full HostRuntime sub-trait reference, ExtensionPlanes/ErasedPlane internals, and a complete worked Rust example, see Native Bundle Runtime ABI v2. Future third-party and closed-source native bundles may later target a compiler-independent C-ABI boundary removing lockstep rustc coupling.


6. .hyabundle Archive Format & CLI Toolchain

6.1 Deterministic Archive Specification

  • Container: Deterministic 7z archive (PUBLIC_MAGIC = 0x37 0x7a 0xbc 0xaf 0x27 0x1c), entries sorted lexicographically with normalized timestamps and permissions so identical inputs yield byte-for-byte identical SHA-256 digests.
  • Pre-prepared metadata (.hya-prepared.json): hya bundle pack (via hya-bundle-tooling) pre-emits .hya-prepared.json inside every .hyabundle archive alongside the declared source closure. At runtime, R1 crates/hya-bundle decodes .hya-prepared.json directly and verifies the archive’s raw file closure and digests without parsing YAML or invoking authoring preparation (crates/hya-bundle-prepare).
  • Safety bounds: Archive ≤ 128 MiB (checked before reading into memory); uncompressed total ≤ 256 MiB; compression ratio ≤ 1000×; rejects symlinks, absolute paths, .. traversal segments, special device nodes, and unreferenced/orphan files outside the manifest closure.
  • Self-check execution safety: When installing interactively (without -y), hya bundle install prompts for user confirmation before executing any package-declared check.command. Self-checks run inside 0o700 temporary directories with 0o600 files and bounded rolling stdout/stderr capture.
  • Artifact naming:
    • Platform-independent bundles (Static / JS / TUI): <publisher>-<name>-<version>.hyabundle (installed built-ins use hya-<name>.hyabundle).
    • Platform-specific Native bundles: <publisher>-<name>-<version>-<target-triple>.hyabundle (installed built-ins use hya-<name>.hyabundle).

A package with a compiled runtime.library includes optional runtime.native_artifact in .hya-prepared.json. It records the packer’s target (Cargo triple), abi_version (integer), abi_digest (64 lowercase hex characters), rustc (compiler identity), and library_sha256 (64 lowercase hex characters covering the packed library bytes). Use a packer built for the same target and ABI as the library. Archive verification checks the library checksum and compares target, ABI version, and digest before running the bundle self-check or protocol smoke. The runtime loader still checks the library’s exported digest before registration. Packages without native_artifact continue to use the runtime check.

6.2 Packaging & Verification Commands

hya bundle provides self-contained packaging and validation commands so authors and external CI pipelines only need the hya binary (never xtask or the Hya Rust source tree):

Terminal window
# Package a bundle directory into a deterministic .hyabundle archive
hya bundle pack ./my-bundle ./my-bundle.hyabundle
# Validate a bundle directory or packaged .hyabundle archive
hya bundle verify --strict --protocol-smoke ./my-bundle
hya bundle verify --strict ./my-bundle.hyabundle
# Install globally or into the current project's .hya/bundles/
hya bundle install -y ./my-bundle.hyabundle
hya bundle install --scope project -y ./my-bundle.hyabundle
  • hya bundle pack <source-dir> <output.hyabundle>: Validates the manifest and resource closure and writes a deterministic public .hyabundle archive.
  • hya bundle verify [--strict] [--protocol-smoke] <package-or-dir>: Accepts either a source directory or a .hyabundle file. --strict enforces SemVer and publisher identity, descriptor checks (no tool or hook descriptor may be an empty {} placeholder, whatever the manifest’s form), MCP placeholder rules, skill and command bounds, and a secret scan of the manifest (bundle.yaml or bundle.hya.md), agent prompts, text resources, and a source directory’s config.example.yml; --protocol-smoke spawns JS process bundles in an isolated temp copy, sends initialize, verifies declared tools/hooks/apis parity, and sends shutdown.

7. Loading, resolution, and precedence

Hya reads installed packages from the user registry and project bundles from the registered Project roots’ .hya/bundles directories. The first root wins among project bundles. Project bundles shadow installed bundles by ID or namespace. Hya omits disabled bundles and bundles with missing prerequisites. Without a declared default agent, Hya uses hya-bare.

--bare excludes both bundle tiers. --pure also suppresses external runtime context and extensions. --bundles <SPEC> selects installed bundles and overrides HYA_BUILTIN_BUNDLES and config.toml bundles.builtin.

runtime.native_artifact in .hya-prepared.json records target, abi_version, abi_digest, rustc, and library_sha256. The loader checks the library’s actual ABI digest at registration. Only a bundle with verified TrustTier::Official can activate tool_plane: full. See the registry protocol for the exact fields and policy.

7.3 Config Injection & Runtime Materialization

  • User configuration:
    • Global installs: ~/.config/hya/bundles/<namespace>/<name>.toml
    • Project installs: <root>/.hya/bundles/<dir>/config.toml
  • Fingerprinting & hot refresh: Hya injects HYA_BUNDLE_CONFIG_FILE and HYA_BUNDLE_CONFIG_DIR on launch and hashes config contents into the bundle’s runtime fingerprint so hya bundle refresh restarts only affected bundle processes.
  • Materialization & cleanup: Bundles with executable processes or local MCP servers materialize into 0o700 temporary directories; when a generation retires or the server shuts down, BundleOwner::shutdown() sends JSON-RPC shutdown, stops child MCP processes, and removes the temp directory.

8. Independent bundle releases

The official bundle repository builds native packages against the four-crate ABI SDK and publishes target-specific signed archives. Core CI uses local fixtures. The host release publishes a target-specific SDK and can notify the official bundle repository with the hya-abi-changed event.