omp packages

pi-pinata0.1.2

Define project subagents in Markdown, delegate work in Pi, and follow each branch from assignment to result.

funsaized Published 5 days ago MIT ~4.2K downloads/mo

Untested on omp

This is a pi package. No one has reported whether it works on omp yet. If you try it, add your result below.

Did it work for you?

Result

One report per person. A new report replaces your old one.

Reports 0

No reports yet.

Readme

Piñata

A subagent implementation that prioritizes a pleasant developer experience. Give independent tasks to agents in Pi, watch their work in one fleet view, and run in shared or isolated sessions.

In Pi, @relay-lead delegates to event-parser and incident-stats. The fleet opens into the parser’s conversation as it writes and tests the code. Back in the main thread, both workers finish and Relay prints the verified report: 4 events, 1 failure.

pi install npm:pi-pinata

Define your first agent · Build Relay

npm CI MIT

Install · Quick start · Fleet · Workflows · Agents · Configuration · Tools · CLI · API · Implementation · Development

YAPSI (Yet Another Pi Subagent Implementation)

I'm one of those black-box-averse folks. In all things software, I like to understand how it works and see what's going on inside. I built Piñata because I wanted a subagent setup that could be wheels on or wheels off, depending on the task and how I configured it. I wanted to see what my agents were doing, jump into a conversation, and keep the workflow as simple or structured as I needed.

I also wanted it to feel good to use. We may not hand-write as much code these days, but I still remember the rush of typing out an elegant solution, compiling it, and watching it run to perfection. Working with agents should leave room for that same sense of craft: trying an idea and watching the results iterate in realtime.

Piñata is open source because I believe the best way to learn is by building things together. If you use it, have an idea, or see a way to improve or extend it, please open an issue or a pull request. I'd love to hear from your experience.

Why Piñata

  • Delegate independent work in parallel and add workers as the task develops. Dependency graphs stage investigation, implementation and synthesis in one request.
  • Keep a worker's conversation and workspace across follow-ups. Each assignment retains its own result, so later answers preserve the original evidence.
  • Browse the agent fleet and message subagents directly from Pi.
  • Work in the same checkout, or give a worker its own Git worktree and review its changes before applying them.
  • Define agents in Markdown or TypeScript. Models, tools, skills and output schemas are all tunable.
  • Inspect failed and cancelled work, recover an original supervised attempt, and reconcile interrupted patch application with its journal intact.
  • Control workers with Pi tools, call the extension over RPC, or embed Piñata in your own app. All three use the same commands and report the same kinds of events.

Piñata handles orchestration and gives your coordinating thread the tools to own the workflow, including testing, review and acceptance. The shipped scout, builder and reviewer are intentionally lean, editable agent definitions. Compose your own agents around the work you actually do!

Install

pi install npm:pi-pinata

Restart Pi to load the extension. Out of the box you get the subagents skill and five prompt templates: /scout, /builder, /reviewer, /pinata-review and /pinata-fix. Choose an available provider/model in Pi.

For the standalone pinata command (runnable outside of a pi session), install the package and Pi host peer in the same npm prefix:

npm install --global pi-pinata @earendil-works/pi-coding-agent@1.5.0
pinata help

pi install installs the extension without adding pinata to your shell's PATH. If you cloned the repository, you can skip the global install. From the repository root, run npm ci --ignore-scripts, then use node bin/pinata.mjs wherever this guide uses pinata.

Piñata targets Linux, macOS and Windows. See platform prerequisites for worker launchers and the Windows compiler requirement.

To uninstall, use pi remove npm:pi-pinata (or the exact registered local path). For the global CLI, use npm uninstall --global pi-pinata.

Quick start

Try the demo

A reviewer is waiting for a scout to finish investigating an HTTP parser. The demo runs in a temporary workspace and makes no provider calls.

  1. Start the demo in your terminal. If you installed the CLI globally, run:

    pinata demo
    

    Or, from the root of a source checkout, run:

    node bin/pinata.mjs demo
    
  2. Press Right, then Enter to open the scout's conversation. Paste and send:

    Trace the HTTP parser and tell me what you find.
    
  3. Press Escape to return to the reviewer's dependencies. Press Left, then Enter to open the reviewer. Paste and send:

    Review the scout's findings and summarize the result.
    
  4. Back in the fleet, press h to see both results.

Try it in your project

  1. Open your project in Pi. Paste this prompt to send a read-only scout through the codebase:

    @scout Where does this project start, where do its tests live, and how do I run them?
    
  2. Press Shift+Down to open the fleet, then Enter to read the scout's conversation. Press Shift+Up to return to the fleet and again to return to Pi. Once the scout finishes, ask a follow-up in the same conversation:

    @scout Find one important behavior the tests don't cover. Show me the relevant files and suggest a test case.
    
  3. To try implementation, read the suggestion first. If you want that test added, send this to the coordinator in Pi:

    Ask a builder to add the test the scout suggested. Review the diff, run the relevant tests, and tell me what passed or failed.
    

To run pinata agents from your own app, see Open a host.

Fleet and conversations

1. See who's working

Press Shift+Down in Pi (or type /pinata) to open the fleet. Each row is an assignment. Use the arrow keys to select one. The details beside or below the list show what you asked the worker to do and what it's doing now.

If a worker is queued, look under Depends on to see what it's waiting for. Needed by shows the same relationship from the other end. Here, the scout is reading the Relay starter code. The reviewer will start when the scout finishes.

Live fleet with scout/1 running and review/1 queued. Under the scout, Needed by lists the reviewer.

2. Talk to a worker

For a running herdr-pi worker, select its Fleet row and press Enter to focus its Herdr workspace. For other assignments, Enter opens the conversation. Type in the message box and press Enter to send. While the worker is running, your message steers its current task. After it completes, a message starts a follow-up in the same conversation. For failed, cancelled or interrupted work, use /continue <text>. “Message queued” means Piñata saved the message; the worker may not have read it yet.

The scout answers a follow-up about what to test. The message box below the answer now says Follow up.

Scroll up to read earlier messages; scroll back to the bottom to follow new output. Press Escape to return to the fleet. Leaving the conversation doesn't stop the worker, and its unsent draft stays there for you.

3. Check the result

In the fleet, press h to see finished assignments. Select one to read its result, or press Enter for the transcript. Press h again to return to your previous view. Finished means execution ended and cleanup was confirmed. Check the status and report before accepting the work.

Finished fleet with the scout selected. Its result cites the requirement and the unimplemented parser.

When you need something else

  • Find a worker. Press / in the fleet to search workers and tasks. From Pi's main prompt, type @ to pick a worker. Send @scout on its own to open the scout, or add a message to give it work.
  • Find out who needs help. Select Attention. A ? marks a worker with a question. Press d to read it and any answers. To weigh in, message the coordinator in the main Pi conversation.
  • Stop work. Press a in the fleet and choose what to stop: one assignment, a worker and its children, or the whole run. Stopping a run includes workers hidden by filters. Output and file edits remain. To leave a foreground wait without stopping workers, use /background.
  • Revisit an earlier run. Press r and choose a run from this project. Saved runs are read-only: you can inspect results without restarting workers.
When Pi notifies the coordinator

By default, Pi notifies the coordinator when all assignments it's watching have ended, including failures and cancellations. The coordinator can keep working or wait for results. Results it already collected don't trigger another turn. To skip automatic notification for new assignments, pass notify: "none" alongside command in pinata_run. Releasing a foreground wait leaves existing notifications in place.

Aborting the coordinator pauses automatic returns until the next user turn. Closing Pi pauses them until you reopen the session. Embedded hosts choose their own notification policy.

Agent mentions

Start a message in Pi with a worker's handle to address it. If no worker matches, an exact agent definition name starts one when you include a task. The selected run takes priority. To specify another visible run, use @run-prefix:scout. If the name is ambiguous, Pi shows the matches and keeps your draft.

If delivery is uncertain, use the displayed /pinata-retry command in the original Pi session and run. Retyping the message sends a new request. See Recovery.

Palettes and accessibility

Open /pinata palette in Pi or /palette in a worker conversation. Filter by name or use the arrow keys to preview a worker row and warning. Enter applies the palette. Escape keeps your current choice. Set ui.palette to use a favorite across sessions.

Pi defaults to inherit, which follows the host theme. In the standalone viewer, inherit uses the terminal's own colors. Try pinata demo for the Piñata palette, or pinata demo --palette rose-pine-dawn for a light palette. Named palettes support 24-bit RGB and 256-color terminals. Basic terminals, TERM=dumb, NO_COLOR, and terminal-default use plain labels and selection markers. Set ui.motion to reduced or off for static activity markers, or PINATA_ASCII=1 for ASCII glyphs. See Configuration.

Compare all 16 palettes

Each screenshot shows the same fleet with the scout selected. For inherit, Pi uses its dark theme here. For terminal-default, the terminal supplies the light text and charcoal background.

Palette Fleet screenshot
inherit Pi’s dark theme with a blue selection and teal worker names
pinata Ink-plum background with a berry selection and raspberry and turquoise worker names
catppuccin-mocha Dark charcoal background with pastel pink, teal and mauve worker names
catppuccin-latte Pale gray background with a cool gray selection and violet reviewer
gruvbox-dark Warm charcoal background with a brown-gray selection and olive activity text
gruvbox-light Cream background with a tan selection and plum worker names
tokyo-night-night Midnight blue background with coral, cyan and lavender worker names
rose-pine-main Dark plum background with a violet-gray selection and soft pink and blue accents
rose-pine-dawn Warm ivory background with a pale rose selection and blue activity markers
dracula Dark gray-violet background with a slate selection and vivid pink and green accents
nord Blue-gray background with a slate selection and frost-blue worker text
one-dark Charcoal background with a gray-blue selection and cyan and lilac worker names
one-light Near-white background with a pale gray selection and magenta worker names
solarized-dark Deep teal background with a lighter teal selection and muted blue-green text
solarized-light Cream background with a sand-colored selection and dark teal text
terminal-default Plain light text on charcoal with a chevron beside the selected scout

Controls reference

These are the default keys. Press ? for help with the current screen and focus. In a worker's message box, type / to browse commands; Tab inserts the selection and Escape closes the list without losing your draft.

Where Input Action
Navigation Shift+Down Open the fleet.
Navigation Shift+Up or Escape Go back one screen or close the open menu.
Navigation Shift+Left / Shift+Right Select the previous or next worker.
Navigation Alt+Left / Alt+Right Select an earlier or later assignment for this worker.
Fleet Up / Down, Enter Open the running Herdr worker’s workspace, open a conversation or toggle a group.
Fleet Left / Right Move between branches, dependency links and details. Right on a link shows that assignment in the fleet.
Fleet Backspace Retrace a jump to a linked assignment.
Fleet Click / double-click Select or open an assignment, toggle a group or open a link.
Fleet /, then Enter / Escape / Ctrl+U Search, then apply, cancel or clear the query.
Fleet Tab Cycle through status filters.
Fleet h / w Show Finished / Queued; press the same key again to restore the previous view.
Fleet d / p Expand or collapse details / preview changes for a worktree assignment.
Fleet a / r Choose what to stop / browse project runs.
Fleet or transcript PageUp / PageDown, Alt+PageUp / Alt+PageDown Scroll the focused pane. The mouse wheel scrolls the pane under the pointer.
Conversation Enter in message box Send a message or run the typed slash command.
Conversation Tab Switch between the message box and transcript.
Conversation Ctrl+O / Ctrl+T Toggle tool output / thinking.
Transcript d / m Expand details / load older messages.
Fleet or conversation Ctrl+X Stop this worker's active and queued work, including children.
Fleet or transcript Ctrl+B / Ctrl+R Release a foreground wait / recover the original assignment. In the message box these are editing keys.
Fleet or conversation Ctrl+L Refresh the selected source.
Help ? Show help for the current view. In the message box, use it with an empty draft.
Message box /worker <id> [assignment], /assignment <number>, /fleet, /main Jump to a worker, assignment, fleet or main conversation.
Message box /steer <text>, /follow-up <text>, /continue <text> Choose how to send your message.
Message box /stop-assignment, /stop, /stop-run Stop this assignment, this worker and its children, or the entire run.
Message box /inspect, /more, /scroll up|down|N, /queued Inspect details, load history, scroll or see queued work.
Message box /background, /refresh, /recover, /reconnect Release a wait, refresh the view, recover an assignment or reconnect.
Message box /replace <new-worker-id> <task> Start a replacement worker linked to this assignment.
Message box /palette [name], /help Choose a palette or open help.

Workflows

A worker has a frozen definition, model, tools, grants and workspace. An assignment is one task or follow-up in its conversation, identified by {run, worker, assignment}. Use references returned by receipts for results, dependencies and patches.

Parallel work and staged graphs

Send this batch to the coordinator's pinata_run tool:

{
  "requestId": "parser-team/start",
  "command": {
    "kind": "launch",
    "workers": [
      {
        "id": "parser",
        "agent": "builder",
        "task": "Implement the agreed parser in src/parser.ts. Preserve unrelated edits."
      },
      {
        "id": "help",
        "agent": "builder",
        "task": "Update src/help.ts for the agreed parser interface."
      },
      {
        "agent": "reviewer",
        "after": ["parser", "help"],
        "task": "Review the parser and help changes. Report defects with source references."
      }
    ]
  }
}

Use launch for the first batch and each later batch. The reviewer above gets the ID reviewer from its agent name. The two builders have distinct IDs so you can address each one. Piñata validates the whole batch atomically, including forward references and cycles. Rejected batches reserve no worker names. dynamic-shared.json is a runnable starting point.

after binds a worker ID to its latest accepted assignment when the dependent is accepted. An explicit full reference selects an earlier assignment. Later follow-ups do not retarget edges or reopen downstream work. Dependencies become ready when exact predecessors end with confirmed cleanup; reported blockers or failed checks do not create an acceptance gate.

For report pipelines, declare known stages together. Workers receive previews and pinata_dependency to list/read complete frozen result JSON. Use the returned next as the next offset. List offsets count entries; result offsets count UTF-16 code units. Previews show at most eight short summaries. Pages fit within 32 KiB and retain artifact references without reading their contents. Use context for explicitly quoted report text. Share files through the checkout or ordinary Git operations.

Control a worker

Action Use
send Steer pending work or start a follow-up after successful completion.
steer Send instructions to active or queued work.
follow_up Queue another assignment in the same conversation/workspace.
continue Explicitly resume stopped/failed work with recoverable context.
cancel Stop an assignment, worker or run; descendants default on.
background Release a foreground wait while work continues.
capacity Change active assignment capacity, including descendants.

To message the parser through pinata_run, supply its worker ID and your text.

{
  "requestId": "parser-team/error-cases",
  "command": {
    "kind": "send",
    "worker": "parser",
    "text": "Add the agreed malformed-input case and report the checks you ran."
  }
}

A send receipt reports messageAction as steer or follow_up and names the exact assignment. Use follow_up explicitly to queue a separate task while the worker is busy or to supply dependencies with after. Follow-ups run in order and preserve earlier results.

Capacity defaults to unbounded. Set execution.maxConcurrent to a positive integer to queue ready work; null removes the limit. Lowering it leaves active work running. Aborting a wait releases the caller without cancelling workers. Cancellation retains partial output and checks cleanup separately.

Durable acceptance, backend transport and worker consumption are separate observations. After a lost reply, inspect the original receipt before retrying with the same request ID and payload. Changed payloads under accepted IDs conflict.

Build Relay

Relay parses JSONL service events, summarizes them and renders a Markdown report. The example exercises parallel modules and dependent integration:

scout -> parser -----+
      -> summarizer -+-> CLI integration -> reviewer
      -> renderer ---+

Create a disposable checkout; setup refuses an existing destination:

node examples/relay/setup.mjs /tmp/relay-exercise
cd /tmp/relay-exercise

Read REQUIREMENTS.md and select available models in fleet.json. In Pi, ask the coordinator to submit its command with pinata_run, inspect exact results and correct failures through follow-ups. The starter has unfinished stubs, so its verifier initially fails. Check the completed work:

node --test
node verify.mjs
git diff

One scout maps interfaces, three builders implement modules, a CLI builder integrates those exact assignments, and a reviewer reports findings. These are example choices. The coordinator chooses checks and follow-ups. Preserve the independent expected report and verifier while repairing implementation. Shared work needs no apply step; Piñata does not automatically commit it.

Workspaces

Mode Behavior
shared Work in the authorized checkout, including non-Git projects. Edits are immediately visible.
worktree Start from a frozen Git base and explicitly apply the worktree's current files.

Tool access and workspace mode are independent. Workers retain conversations, results and cleanup evidence without per-assignment file snapshots or completion commits. Shared edits are already in the checkout. The coordinator owns testing, review and integration; it can apply work within the user's authorization without asking for a separate approval each time.

In a shared checkout, give workers separate areas when possible and have them report overlaps to the coordinator. Use after when one assignment needs another's edits. Workers should reread files before editing and preserve changes they did not make. The coordinator resolves overlapping changes and chooses when to run checks or commit. Piñata does not register writers or lock project files.

New worktrees include dirty starting content by default; includeUncommitted: false selects committed content. Follow-ups keep the worktree; changing modes needs a new worker. Results expose worktree.path and worktree.base for inspection with Git. The worktree remains available after failure or cancellation. Its files are mutable: an old assignment reference does not preserve an old version. Use Git commits or patches when a workflow needs named versions or transfers between worktrees.

Dependencies and setup

Use after for assignment ordering and the dependency tool or quoted context for reports. Use shared files or coordinator-selected Git operations to transfer code.

The source checkout's .worktreeinclude selects ignored local regular files, such as .env.local or local/**. Piñata freezes their identities at acceptance and copies them during initial preparation. Changed sources, links and unsafe paths are refused or recorded as omitted; existing destination files and follow-up edits are preserved. Included contents are excluded from application even if ignore rules change. Limits are 1,000 files and 16 MiB per file. Use setup for dependencies.

Setup runs only in writable isolated work. setup: false disables it; a string selects a shell command; omission can detect a root lockfile and package manager. Shell capability is required. Detected setup without that grant is skipped with a reason; an explicit command is rejected. passEnv selects safe environment names; values are supplied at execution and are not serialized. Success is retained for the relevant worker and input identity. Failed setup preserves partial edits; inspect uncertain interrupted setup before deciding to run it again.

Apply isolated work

Submit the command in isolated-follow-up.json with pinata_run. Inspect its exact result with pinata_status and use the returned worktree.path and worktree.base:

git -C WORKTREE_PATH diff BASE_COMMIT
git -C WORKTREE_PATH status --short

Send corrections with pinata_run using send, wait for that receipt's exact assignments, and call pinata_integrate with the latest stopped ref and destination. Embedded hosts use the same send and apply commands.

Apply selects the current files, including untracked files, using the worker's latest stopped assignment reference. It does not select that assignment's past output. Inspect the accepted operationId and its outcome. Later applications deliver the delta from the last applied Git tree, even within the same assignment. Retry the same request ID to retrieve the original operation; use a new ID to select newer edits. Apply preserves HEAD and the index.

Before applying, arrange a handoff: let affected workers finish or cancel them and confirm cleanup, then keep the source worktree and affected destination files still until apply returns. Coordinate other sessions and editors too. Piñata checks the selected worker's stopped assignment, but does not track other checkout writers.

Apply checks paths, objects, destination identity and expected content. Conflicting edits are reported for the coordinator to resolve; apply does not merge them. These checks can detect changes, but cannot prevent concurrent edits. A small lock in .pinata/applications/lock/ serializes apply, rollback and recovery against the same application journal. It does not block workers or editors.

Each application journals before and after blobs and cursor meaning. rollback reverses only matching destination content; later edits conflict. reconcile selects the retained operation and owner epoch. Application blobs and helper evidence live in the destination's .pinata/applications/artifacts, so later runs can verify and recover earlier operations. Older journals copy missing blobs from the attached run when read. Reopen the originating run first if a legacy blob is unavailable; do not delete its artifacts. Preserve journals, worktrees and artifacts until the outcome is understood. See recovery.

Custom agents

Shipped agent Tools Purpose
scout read, grep, find, ls Trace code, data flow and risks.
builder read, write, edit, bash Implement a concrete task and report actual checks.
reviewer read, grep, find, ls, bash Find defects and missing evidence in a supplied change.

The reviewer requests write access because shell execution requires it. Its instructions leave source files and commits untouched; this is a behavioral instruction, and shell access can mutate files. The coordinator chooses checks and decides acceptance.

Define your first agent

Save a specialist as .pi/pinata/agents/api-scout.md:

---
schemaVersion: 1
name: api-scout
handoffDescription: Map API behavior and compatibility risks.
tools: [read, grep, find, ls]
pinata:
  access: read
  color: accent.cyan
---

Trace the assigned API from callers to implementation and tests. Return source
references, compatibility concerns and unresolved questions. Do not edit files.

Validate with pinata agents show api-scout --workspace . --json, then use @api-scout Trace authentication errors in Pi or "agent": "api-scout" in a worker command.

Discovery and fields

Definitions resolve from lowest to highest precedence:

  1. Packaged agents/.
  2. <Pi agent directory>/pinata/agents/, normally ~/.pi/agent/pinata/agents/.
  3. Project .pi/pinata/agents/.

Repeatable --definitions <directory> replaces the list in supplied order. Invalid selected overrides fail with path and field errors. Names match filenames and contain a lowercase letter followed by up to 31 lowercase letters, digits or hyphens. agents list|show <name>|validate --json returns source paths and digests.

Field Type/default and meaning
schemaVersion Required 1 in Markdown.
name, handoffDescription Stable handle and discovery description.
Markdown body Instructions; project instructions are discovered each assignment.
model Optional exact provider/id.
modelSettings.reasoning.effort off, minimal, low, medium, high, xhigh, max.
tools Default []; named tools checked against host grants/classifications.
handoffs Default []; allowed child definition names.
outputType Registered schema name, or a Zod schema in trusted TypeScript.
pinata.access read by default; write requires a grant.
pinata.workspace Default shared; explicit declaration overrides run workspace config.
pinata.skills Default []; files/directories relative to the definition source.
pinata.fallbacks Default []; up to five model candidates.
pinata.color accent.blue/cyan/green/yellow/orange/red/pink/purple or six-digit hex.
pinata.inheritContext Default none; parent requests a filtered checkpoint.
pinata.memory Default { "scope": "none", "access": "read" }.
pinata.delegation.maxDepth Default 0; requires handoffs and a scoped host grant.

Acceptance freezes the definition, model, grants, tool providers, skills and workspace plan. A new worker adopts edited frozen resources; follow-ups preserve the accepted worker. Project AGENTS.md discovery refreshes each assignment, including new or renamed files in non-Git projects.

Only explicitly selected skills load. Piñata freezes source and resources and materializes those bytes for execution. Skills cannot broaden tools or grants. Custom extension providers are trusted host code; their frozen source identity is checked before load. pinata agents validate also checks selected skill files and resources without opening a runtime or making model calls. Missing skills report the resolved path and pinata.skills field. Validation does not establish model or tool availability.

Typed definitions and reports

For a typed report, export an agents array from an explicit bootstrap module:

import { defineAgent } from "pi-pinata";
import { z } from "zod";

export const agents = [
  defineAgent({
    name: "api-auditor",
    handoffDescription: "Map API compatibility risks.",
    instructions: "Inspect the requested API and report concrete findings.",
    tools: ["read", "grep", "find", "ls"],
    outputType: z.strictObject({
      files: z.array(z.string()),
      risks: z.array(z.string()),
    }),
  }),
];
pinata agents show api-auditor --bootstrap ./pinata-agents.ts --json
pinata agents list --bootstrap ./pinata-agents.ts

defineAgent defaults schemaVersion to 1. Typed and Markdown definitions cannot share a name. The optional submit_result worker tool submits a final report and ends the assignment on success. Use it only when ready to finish, never for progress updates. Later tool calls in the same batch are blocked, and queued input does not continue a reported assignment. The coordinator can start an explicit follow-up. It accepts:

{
  "summary": "Traced authentication errors.",
  "data": { "files": ["src/auth.ts"], "risks": ["Missing expiry test"] },
  "assessment": {
    "findings": ["Expiry behavior has no regression test."],
    "claimedChecks": [],
    "blockers": []
  }
}

outputType validates data. Zod refinements, including asynchronous refinements, run in the original trusted validator. Discovery exposes input JSON Schema, which cannot recreate callbacks. Transforms and non-JSON types are rejected. Failed optional reports remain as reporting errors; ordinary final text remains valid output.

If the model hits its output limit on its final response before submitting a report, the assignment fails with execution.outputTruncated: true. The result summary keeps the text the model returned, even if it ends mid-sentence. The fleet and coordinator show why the response stopped. Usage and cleanup are recorded separately.

Workers freeze the selected bootstrap path, source bytes, digest and schema descriptor. Missing or changed bootstraps fail before execution. Editing an already loaded module requires a fresh host process and worker. Only host code or explicit --bootstrap can select executable definitions.

Worker messages

Workers can use pinata_message for progress, findings and questions while they continue working:

{
  "messageId": "registry-ready",
  "to": "coordinator",
  "text": "The initial registry is ready; discovery is continuing."
}

Omit to to address the worker's original parent assignment, or the coordinator for a root worker. Use "coordinator" explicitly to reach the primary agent, or {"worker":"builder"} to address another active or queued worker in the same run. Add assignment to select an exact assignment. Stopped or canceled recipients reject new messages; a message never starts or resumes an assignment.

The host supplies the sender identity. The receipt confirms durable recording; delivery and consumption remain separate observations. Reusing messageId with the same input returns the original receipt; changing its content rejects the retry. Messages arrive as attributed worker data and grant no command authority. Pi displays coordinator messages and includes them in its next provider request without starting an extra coordinator turn. Peer messages use the existing input queue, including its consumption checkpoints. Concurrent completion or cancellation can leave a recorded message unread.

Read retained messages with pinata_status and {"query":{"kind":"messages","since":0}}. The returned cursor is the next since value; an optional worker filter selects messages sent or received by that worker. The query also works through extension RPC, the CLI and saved-run viewer.

Ask the coordinator for a decision

When a worker needs a decision, it calls pinata_message with a stable message ID and a question. A decision goes to the main coordinator, including from nested workers.

{
  "messageId": "parser-policy",
  "decision": "wait",
  "text": "Should malformed lines be skipped?"
}

With "wait", the worker keeps its assignment and capacity slot. The tool returns the coordinator’s text in answer. Other workers keep running. A worker with independent work can use "continue" to return immediately and receive the answer as steering on the same assignment while it is active.

The coordinator calls pinata_wait with includeDecisions: true and the exact targets from its launch receipt, or a list of workers. The wait returns decision_requested with outstanding questions from those assignments or their delegated children at any depth, including questions recorded before the wait began. Ordinary progress messages do not end the wait. A decision request never starts an idle coordinator turn. Use a decision-aware wait when a worker might block for an answer.

Pass one or more returned decisionId values to pinata_answer, then wait again:

{
  "requestId": "answer-parser-policy",
  "answers": [
    {
      "decisionId": "<returned decisionId>",
      "text": "Skip malformed lines and count them."
    }
  ]
}

The runtime records the whole answer batch together. A repeated, stale or unknown decision ID rejects the batch. After an uncertain reply, retry the same request ID and payload. An answer stays bound to the assignment that asked the question. The messages query includes the recorded answer. Its since cursor returns a question again when the coordinator answers it.

Configuration

Layers resolve from personal <Pi agent directory>/pinata.json, project .pi/pinata.json, then run config. Omitted fields preserve lower layers. models, fallbacks and toolProviders merge by entry; other supplied fields replace the corresponding field. Worker overrides resolve into frozen launch data.

{
  "schemaVersion": 1,
  "workspace": "shared",
  "backend": "in-process",
  "mode": "observe",
  "models": {
    "builder": { "provider": "provider", "id": "model", "thinking": "high" }
  },
  "execution": { "maxConcurrent": 4 },
  "ui": { "palette": "catppuccin-mocha", "motion": "reduced", "keys": {} }
}
Field Default/behavior
schemaVersion 1.
workspace shared; optional worktree.
backend in-process; optional process, herdr-pi.
models {}; per-agent model objects and optional default.
fallbacks {}; per-agent/default lists of up to five available-model candidates.
execution.maxConcurrent null (unbounded), or a positive active-assignment limit.
mode lean; observe adds activity excerpts.
toolProviders {}; named {extension, tools} providers.
webExtension Optional provider for web_enable, web_search, fetch_content, get_search_content.
passEnv []; safe setup environment names, with values excluded from evidence.
setup Omitted: detect root locked dependencies; false: disable; string: explicit command.
worktreeRoot Optional host worktree location.
codemode true; Pi coding wrapper with underlying capability checks.
includeUncommitted true; include dirty content in a new isolated base.
ui.palette, ui.motion, ui.keys inherit, full, {}.

Model precedence is worker request, per-agent config, definition, default config, then parent model. Definition reasoning defaults to off when its model is selected. Fallback candidates resolve before launch and retain provenance; execution failure does not silently rerun on another model. Model objects contain provider, id and thinking. Definition discovery alone does not promise model availability.

Key actions are openFleet, parentScreen, previousWorker, nextWorker, previousAssignment, nextAssignment, stop, background, recover, refresh, scrollUp and scrollDown. Invalid/reserved or duplicate bindings fail explicitly; screen help reflects configured bindings.

Built-in read, grep, find, ls have read access. write, edit, bash and powershell need write access. Custom providers default to write classification unless host code classifies them otherwise; known web-provider tools are read-oriented. Requests must fit the frozen tool list and grant. Loader and control environment names such as NODE_OPTIONS, LD_PRELOAD, DYLD_INSERT_LIBRARIES and PINATA_* are refused in passEnv.

Host grants

Authority comes from the host, separately from project config and model requests. The default host grants ordinary read/write tools and both workspace modes. Inheritance, memory and delegation default off.

In Pi, /pinata-grants <json> followed by /pinata-new selects grants for a new run. Personal <Pi agent directory>/pinata/grants.json supplies persistent grants across workspaces; command and integration grants take precedence. Invalid personal grants fail with their path. Accepted workers keep their grants.

Headless hosts use --grants <file>; integrations use HostOptions.grants. Inspect pinata.grants.v1 before editing it. The grant recipe contains every required field. Project config, skills, reports and memory cannot grant authority.

Context and memory

pinata.inheritContext: parent requests a filtered parent conversation. It requires a host grant, supporting backend and available checkpoint. Pi can supply the current parent branch; an independent headless host without parent context reports unavailable. Piñata retains supported messages, complete tool pairs and compaction provenance, excluding host controls and incomplete pairs. Import does not replay tools. Use task text or context for explicit quoted background.

Memory scope Use
none Default; no memory tools.
worker Retained notes for one worker.
project-agent Notes for one agent within one canonical project.

The host must grant the same scope and requested access. There is no cross-project global profile. pinata_memory_read returns a revision; edit/clear requires that revision. Concurrent writes conflict: read, merge and retry. Clear records an empty revision while preserving history. Model-written notes remain subordinate to current instructions and grants.

Pi provides direct controls without a model turn:

/pinata-memory inspect scout
/pinata-memory edit scout {"expectedRevision":0,"text":"Retained notes","data":{"checked":true}}
/pinata-memory clear scout 1

Use the inspected revision. Inspection reports scope, value and provenance; edit replaces the value, with optional data. These controls use the accepted worker's scope and write grant, accept no path override and preserve a newer editor draft.

Nested delegation

Enable nesting when a worker should divide a workstream and synthesize its children. Independent tasks can remain siblings. Child ancestry comes only from the bound pinata_children tool; after, names and origins do not establish parentage.

The delegator definition, fleet command and grants form a complete opt-in example. In Pi, copy the definition to .pi/pinata/agents/delegator.md, paste the grant JSON into /pinata-grants, then use /pinata-new. For persistent personal setup, use <Pi agent directory>/pinata/agents/ and pinata/grants.json.

Submit authorized-nested.json through an embedded host with the example definition directories and grants, or use its command in pinata_run after configuring Pi.

The parent needs positive depth and allowed handoffs. The host grant must permit depth, child definitions, tools and workspaces, and the backend must support nesting. pinata_agents reports effective delegation.enabled and each parent's usable scope or disabled reason. Plan from that discovery. Model config alone does not create an agent or enable delegation.

Children use their definitions within the parent's ceiling. Read-only parents cannot grant write access. Child tools control only descendants and never receive a root source or supervisor credentials. IDs share the run namespace; prefix them by workstream and batch independent children in one add call.

Descendants share root assignment capacity. A waiting parent occupies a slot. At capacity one, pinata_child_wait returns capacity_blocked: finish the parent with child references, let children settle, then have the coordinator follow up with that same parent and exact after references for synthesis. dependency_blocked also requires ending the parent. Polling cannot free its slot. Normal parent completion leaves accepted children running; cancellation includes descendants by default. Completion notices do not automatically start another parent turn. The shipped nested instructions contain exact patterns.

External triggers

Coordinators and integrations decide when to submit work. An external timer can call an embedded host or an extension adapter using canonical commands and durable request IDs. Piñata dispatches accepted assignments as dependencies and capacity allow. Use an external timer for recurring work.

Backends and lifetimes

Backend Execution
in-process Pi sessions in the host. Default; avoids worker process startup and releases idle sessions after persistence.
process The same Pi adapter in a supervised Node worker with durable transport and original-attempt reattachment.
herdr-pi An interactive Pi worker in the root pane of a new workspace in your running Herdr session.

Backends share the frozen contract for tools, context, skills, memory, continuation and workspaces. Unsupported capabilities fail before launch. Missing Herdr does not switch the request to another backend.

Herdr workspaces open in the background. Open a worker’s workspace to see its conversation and type directly into Pi while it works. You can also steer the same session from the coordinator. After Piñata saves the result, it closes the worker pane and leaves any panes you added open.

New process and herdr-pi workers default to surviving. If the coordinator crashes, these workers can keep running and the next coordinator can reattach to the same attempt. Set lifetime: "attached" on a worker to stop it when its host exits. In-process workers always run attached. Explicit shutdown stops workers of either lifetime.

Payload exit does not establish descendant cleanup or complete output. The POSIX supervisor controls its owned group through a live nonce-bound authenticated channel. Windows uses a creation-time Job Object. Stopped receipts require matching ownership and termination evidence. Missing, escaped or ambiguous activity stays unconfirmed; inspect and recover it before continuing that worker or handing off its files. Process output drains and synchronizes separately from payload exit. Each tiny streaming chunk incurs durable transport work, which can affect completion latency.

Headless operation

Programs own fleets through host API. Submit canonical commands, wait for exact assignments, retrieve results and close the host in finally. embedded-host.ts shows this lifecycle.

The CLI discovers schemas and definitions and reads retained runs directly:

pinata demo
pinata view RUN_DIRECTORY
pinata status RUN_DIRECTORY --json
pinata result RUN_DIRECTORY map 1 --json

Git projects use a store under the common Git directory; non-Git projects use .pinata/runs. openHost({directory}) selects a run store. Canonical workspace identity handles aliases consistently. Saved views never claim ownership or control workers. Recovery and patch application require Pi or an embedded owning host.

Tools

Pi supplies tool schemas automatically. Start with pinata_agents for definitions and effective capabilities. Inspect installed contracts with pinata tools --json or pinata schema <name> --json. For an offline reference, the JSON catalog collects schemas, tool inputs and outputs, command and event names, and CLI help in one file.

Coordinator tool Input/purpose
pinata_run command, optional requestId; launch, send, continue, capacity, background and explicit create/add/follow_up.
pinata_steer worker, messageId, text, optional requestId.
pinata_cancel scope, applicable worker/assignment, optional descendants, requestId.
pinata_answer answers with decision IDs and text, optional requestId.
pinata_wait Optional workers or exact targets, next and includeDecisions.
pinata_status Canonical query, default status.
pinata_agents Discover definitions, model defaults and effective grants.
pinata_integrate Exact ref, destination, optional requestId; observe its application operation.
pinata_rollback operation, destination, optional requestId.
pinata_recover Optional exact targets; inspect/reattach original attempts.
pinata_page cursor returned from a paged tool reply.
Worker tool Availability
submit_result Optional final report; ends the assignment on success. outputType can refine data.
pinata_message Send to the coordinator, parent or a pending peer without ending the assignment.
pinata_dependency Exact frozen dependency results only.
pinata_children Explicit scoped delegation grant.
pinata_child_status, pinata_child_wait Same grant; descendants only.
pinata_page Previously exposed child-tool output in this worker session.
pinata_memory_read Granted worker/project-agent memory.
pinata_memory_edit, pinata_memory_clear Scoped memory write grant and expected revision.

Coordinator details retain pinata.surface-reply.v1; pinata_page returns pinata.tool-page-reply.v1. Model content fits within 32 KiB. Larger replies return immutable UTF-8 JSON fragments with offsets, digest and nextCursor. Pass it as cursor to pinata_page and concatenate text in offset order. Details, CLI JSON and immutable evidence retain the full value. Cursors expire with the host and cannot address arbitrary files or artifacts. After reconnect, re-query the read or original receipt for fresh pages.

Commands and queries

Envelopes contain requestId, optional expectedRevision and command. Accepted receipts name the revision, exact assignments, messages and any application operation. Stale expected revisions reject. Stable IDs make acceptance retries idempotent; they do not promise exactly-once arbitrary external tool effects.

Command Behavior
launch Start or extend a run with a worker batch. The first launch accepts config.
send Message a worker by ID with text and an optional messageId.
create, add Atomically accept worker batches; create can include config.
follow_up Queue with worker, messageId, text, optional after.
steer, continue Address a worker with message ID/text.
answer_decisions Answer one or more open requests on their original assignments.
cancel Assignment/worker/run scope; descendants default on.
background, capacity Release a wait or select positive/null maxConcurrent.
apply Apply current worktree files after coordinator handoff; check conflicts.
rollback, reconcile Recover a selected journaled application.

Worker requests require agent and task. The optional id defaults to agent. Other options include origin, messageId, after, workspace, model, backend, lifetime, context, inheritContext, memory, delegation. origin identifies an earlier assignment in the same run. It copies no context or files and adds no dependency; supply these explicitly when replacing work.

Queries: status, messages, config, receipt, result, events, schemas, definitions, conversation, conversation_preview, changes, application, wait. Result, conversation, preview and changes select ref; receipt selects requestId; application selects operationId. Conversation paging uses returned cursor; events and messages use since. Messages can filter by worker. Unnamed model-facing schema discovery returns an index. Request a named schema or tool for its fields.

conversation_preview returns up to 4,096 code points of assistant text, with its source and completeness. It searches at most 512 recent entries within 2 MiB of retained evidence. A checkpoint fallback reports its source without attributing whole-worker history to the selected assignment. Full conversation queries retain their complete evidence checks.

Errors and versions

Domain error Meaning
invalid_input Malformed/rejected fields.
dependency_missing Unavailable assignment reference.
capability_denied Request exceeds authority.
unsupported Selected host/backend/resource lacks capability.
conflict Stale revision, changed accepted payload, state or content.
owner_unconfirmed Ownership/cleanup cannot be established.
context_unavailable Retained conversation/resource cannot be restored.
commit_unknown Durable write outcome is uncertain; inspect the receipt.

Surface errors also include internal_error, protocol_version, unauthenticated, transport_closed, transport_limit, with an optional field where useful.

Named schemas use v1. Package releases and data versions are independent; the runtime rejects unknown data versions. JSON Schema describes shape. Canonical validation also checks grants, graph references, resource identity and journal consistency. Pi may coerce scalar tool input before validation; CLI and extension RPC do not.

CLI reference

pinata help prints installed grammar; --json emits one JSON value per line. Use - for stdin where a file argument is accepted.

Command Purpose
view <directory> Saved viewer; optional --palette.
query <directory> <file> Read-only canonical query; - reads stdin.
status, logs Inspect a directory; logs accept --since <revision>.
result, conversation, changes <directory> <worker> [assignment]; omission selects latest.
schema [name], tools Discover canonical schemas and tool contracts.
agents list, agents show <name>, agents validate Discover/validate definitions.

Discovery accepts --workspace, --agent-dir, repeatable --definitions and a trusted --bootstrap <module>. Inspection accepts --cursor, --since, --palette and --json where applicable.

Exit codes: 0 observed, 1 failed/uncertain application evidence, 2 invalid or rejected request. Execution completion does not certify correctness.

Pi commands: /pinata, /pinata help, /pinata-main, /pinata-fleet, /pinata-conversation <worker> [assignment] [--run <id>], /pinata-palette [name], /pinata-schema [name], /pinata-grants <json>, /pinata-new, /pinata-retry <run>:<input-token>, /pinata-memory inspect|edit|clear ....

Result cards include the run ID in their conversation command. An older card opens its recorded assignment, even if the selected run has reused the worker name. Saved runs open read-only.

A schema describes a data format, including its fields and allowed values. /pinata-schema lets you search by name and page through one format at a time. Browsing stays in the terminal and preserves the coordinator's model context. Use pinata schema <name> --json to read the full definition from a script.

Package API

Root pi-pinata exports defineAgent, openHost, Runtime, bindRuntime, openSavedSource, ToolPages, toolContentBytes, exportSchemas, parseSchema, schemaRegistry.

Public types: AgentDefinitionInput, DefinedAgent, Host, HostOptions, RuntimeOptions, RuntimeSource, AssignmentRef, CallerAuthority, CommandEnvelope, CommandReceipt, RuntimeEvent, SurfaceCall, SurfaceReply.

Entry Boundary/exports
pi-pinata Full root host API; loads Pi SDK.
pi-pinata/host openHost, defineAgent, builtinTools and host types.
pi-pinata/runtime Pi-independent Runtime and port/options types.