omp packages

@llblab/pi-actors2.0.0

Local Actor Kernel for Pi

GitHub Actions Published 3 days ago MIT ~2.5K 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-actors

pi-actors banner

Local Run kernel and persistent tool registry for Pi.

Recipe --spawn--> Run
Run = Recipe + Trace + Control

An actor is any runnable local capability: a script, tool, service, pipeline, or subagent. A Recipe is its reusable executable definition. actors_spawn creates a Run—one concrete actor instance—which captures its Recipe, appends observable Trace, and may consume actor-local Control.

Local Coordinator Model

Multi-instance systems commonly put instance creation and routing in an external gateway. pi-actors supports a different topology: the current Pi instance remains the coordinator, companion extensions such as Telegram provide presence, and explicit Runs perform bounded delegated work. The coordinator receives high-level outcomes, decomposes them, stays available for decisions, and owns integration plus final validation instead of becoming another undifferentiated worker.

This topology does not require every task to become a subagent. Short work with one natural validation boundary stays inline; delegation pays when clean context, asynchronous execution, independent judgement, parallel ownership, or coordinator availability exceeds its coordination cost. Bounded implementation can run with reasoning off while the coordinator selectively launches clean-context reasoning-enabled reviewers; several independent reviews can provide broader evidence than one author self-review. Boundary-delivered completion batches, durable Trace, and declared artifacts replace tight polling loops.

Design notes for portable Recipe composition bundles and CodeMode interoperability are recorded separately. JSONL bundle loading is not implemented or included in the current UX/AX release; host CodeMode, when available, calls existing tools rather than replacing the Run kernel.

Where Recipes Live

A Recipe is part of a Skill, a file in ~/.pi/agent/recipes/ (then it is an agent tool), a file in its drafts/ folder (a draft), or written on the fly and passed to actors_spawn as template. There is no separate saved-but-hidden library. See capability memory.

Install

Requires Node.js 22.19.0 or newer and Pi 1.0.0 or newer.

From npm:

pi install npm:@llblab/pi-actors

From git:

pi install git:github.com/llblab/pi-actors

The package contributes the extension and four Skills for actor operation, music playback, project work, and swarm orchestration. Manifest-loaded packages expose those Skills through the package manifest so Pi resource filters and package provenance remain authoritative; a checkout auto-discovered directly under Pi's user or project extensions directory contributes its source Skills even when Pi selects the checkout's compiled entrypoint.

Upgrade safety

Before moving from the old runs/ layout, finish or stop its Runs and settle pending deliveries with the previous installation. The current layout leaves those files untouched and does not discover, migrate or stop that work. See Run storage for current behavior and CHANGELOG.md for release-by-release changes.

Public Tools

Only actors_tool_register, actors_spawn, actors_control_apply, and actors_inspect are advertised for new calls. Explicit legacy register_tool, spawn, message, and inspect dispatch remains compatible with saved calls through the same schemas and executors. Saved Recipe identities and completion text are not migrated. Control applies Run/runtime actions, not chat. See Tool Registry for compatibility visibility, namespace and collision rules; this change does not reload an already running host.

actors_spawn

Create a Run from an active-Skill Recipe, an explicit Recipe file, or an inline command template:

actors_spawn template="sleep 30" as=run:demo
actors_spawn recipe=project-work/repo-health values={"repo":"/work/project"}
actors_spawn recipe=music-player/playback values={"source":"/music"}
actors_spawn template="make test" as=run:test

Use a Run when work may outlive the current turn, needs steering, fans out, produces artifacts, or must remain inspectable. Short foreground commands can remain ordinary tools.

actors_control_apply

Send one exact Control:

{
  "target": "run:player",
  "action": "pause",
  "input": { "reason": "operator" },
  "verbose": false
}

Run targets accept Recipe-declared actor-local actions and the runtime-owned kill, for a Run of the current session. kill is not Recipe-declared. target=runtime actions are not supported.

actors_inspect

Results arrive on their own, so inspection is for diagnosis:

actors_inspect run=test
actors_inspect

With run, one summary: status, recipe, start and finish, exit code, the last events, actions you can send while it runs, queued Controls, and paths to the Run directory, its Recipe file (the saved draft for an inline command), result and output. Without arguments, the current session's Runs with their status. There are no views or other targets; read the listed files with ordinary tools for more. Both require the coordinator session that owns the Run; a name alone is not authorization. See inspection.

actors_tool_register

Persist a maintained Recipe with actors_tool_register name=<tool> from=<skill>/<recipe> defaults={...}, or register a trusted command through the separate template mode. Definitions live under ~/.pi/agent/recipes. Treat an exposed tool as callable in the current session only when the result reports callable_now: true; persistence, Recipe spawning, and registered-tool invocation are distinct states.

Recipe

Recipes can declare:

  • named typed args, inline fallbacks, configuration defaults, and composition values;
  • imports and command-template composition;
  • retry, failure, recovery, repeat, concurrency, and timeout policy;
  • artifact paths;
  • control: ["action"] only for inputs a service actually consumes.

Example controlled Recipe:

{
  "async": true,
  "control": ["pause", "resume", "stop"],
  "artifacts": { "state": "{state_dir}/player-state.json" },
  "template": "{skill_dir}/scripts/player.mjs --state-dir {state_dir}"
}

Ordinary one-shot Recipes should omit control. Recipe imports compose definitions inside one Run; they do not create peer actors.

{
  "imports": {
    "review": "swarm/subagent-prompt",
    "save": "actors/file-write"
  },
  "args": ["prompt:string", "report:path"],
  "template": [{ "name": "review" }, { "name": "save", "values": { "path": "{report}" } }]
}

Skill Recipe identity is <active Skill name>/<Recipe filename stem>. Recipe files have no top-level name; the filename is identity. SKILL.md name remains Pi host metadata and matches the Skill directory—pi-actors adds no second Skill identity field.

References have two classes: exact active-Skill identities such as project-work/repo-health, and explicit .json / .md paths. Entry file paths resolve from invocation cwd; relative imports resolve from the importing Recipe's directory; absolute paths remain exact. File-backed Recipes receive immutable {recipe_dir} and Skill Recipes also receive {skill_dir}. Skill components never become tools automatically.

String command-template leaves execute directly without shell interpretation. Use template arrays for sequencing or an explicit trusted shell/script when shell semantics matter.

Trace

trace.jsonl contains bounded structured observations:

{
  "id": "cfd0…",
  "ts": "2026-01-01T00:00:00.000Z",
  "kind": "progress.update",
  "summary": "Indexed 40 files",
  "data": { "files": 40 },
  "level": "info",
  "attention": "notify"
}

Trace fields are exact: id, ts, kind, and optional summary, data, level, attention. Address, sender, recipient, reply, and routing fields fail validation. Trace is a bounded retained suffix, not an audit archive: the canonical authority appends within 2,048 events and 4 MiB or atomically keeps the newest suffix plus one warning-only runtime.trace_compacted marker. That marker means older history was discarded; result.json, steps.json, terminal state, and declared artifacts retain their own authority. actors_inspect run=<name> shows the latest events. Reads are newline-safe and deterministic; first-party scripts never write this file directly.

Generic command lifecycle is Trace-only: runner-owned command.done records preserve completion and execution evidence but never request or project attention, including malformed legacy records carrying steer. There is no Recipe-level command-completion delivery switch. Semantic attention is explicit: notify shows visible status without a model turn, followup supplies ordinary checkpoint context, and steer requests urgent delivery at Pi's next safe assistant/tool boundary. notify and followup remain retained wake hints that may compact away, so persist recovery state or an artifact first. steer is admitted to the bounded owner delivery journal before deliverAs: "steer", acknowledged only in exact model-bound context, and never suppresses the eventual root-terminal batch. Store large evidence in artifacts or bounded execution captures. New urgent steers keep the canonical checkpoint and whole optional references within 16 KiB, explicitly counting omitted paths instead of cutting a path; saved envelopes retain their original text. Essential text that cannot fit remains retryable before admission, not partially delivered. Ordinary notify/followup shares exact reference spelling and explicit eight-slot coverage; its wake policy is unchanged. Legacy body and steer-diagnostic clipping explicitly marks unknown omission counts when no retained privacy context admits safe numbers; it is not a new privacy or completeness guarantee.

Ordinary finite Runs project terminal results through one root-coordinator completion scheduler. Nested Actor Pi sessions never emit completion turns, and a Run cannot be launched from inside one. While the coordinator Pi is active, the next completed turn_end boundary snapshots all ready results into one immutable bounded batch, appends one visible custom message after the full tool batch, and requests one next model step. This overlay uses boundary entries, not Pi's native steering or follow-up queue, so the model can integrate fresh results before its current run settles. Already-idle Pi retains a short debounce and one automatic follow-up wake. The operator and model receive the same batch with bounded actor outputs. Proposed boundary entries stay pending until exact model context or bounded active-session evidence proves acceptance; an idle send finalizes on successful Pi acceptance without requiring a later context callback. Sequence, parallel, repeat, and imported branches remain internal, while separately launched Runs retain exact independent generations. Silent Runs and synchronous stop acknowledgments remain non-projecting.

Completion cards put bounded YAML metadata above the Run's actual output or recorded error. A cut mapped to an output file ends with [Read from line N]; follow that file entry if you need the rest. File locations are starting points, not a full inventory or a guarantee that a declared artifact was produced. When whole results do not fit, the card can point to the captured-member inventory. Replay keeps the captured text and locations without refreshing them.

Launch receipts use bare block YAML and distinguish an existing Run reuse from a fresh launch. A complete file-location row is enough to start investigation; otherwise the compact receipt can point to actors_inspect. Full actors_spawn verbose=true renders selected metadata separately without changing the machine details.

Runtime argument guidance stops at the execution handoff. Failures after an executor entry or launcher handoff keep their original cause/details, even if their wording resembles a missing or invalid argument. Later-step failures can follow partial work: do not blindly repeat the invocation. This changes presentation, not retry policy or native termination guarantees.

Control

An exception does not guarantee an unapplied action: actor-local delivery can fail after handling is recorded. Use existing owned evidence rather than replaying the action. The partial-failure evidence map distinguishes these paths from still-gated native stop receipts.

Controls persist to controls.jsonl before transport. One token-owned lock rejects a 65th pending Control or 1 MiB rewrite before admission, fails closed on malformed or stale-generation evidence, and atomically admits one record. Canonical transitions retain a 128-terminal tail, expected-state fencing, and 4 KiB errors. Admitted nonterminal Controls never expire automatically. Every record carries immutable run_instance_id. actors_inspect run=<name> reports the actions a running Run accepts and its queued Controls.

Lifecycle kill uses the same actors_control_apply tool and reaches only an exact Run of the current session:

actors_control_apply target=run:<id> action=kill

Compact Control replies report an understandable action stage instead of dumping status objects: queued/delivered is not handled, and a kill attempt leaves full termination explicitly unconfirmed. Only a relevant evidence hint is shown (Control for actor delivery, Trace for a stop attempt, owned inventory after identity replacement). Use verbose: true on the original request for full JSON, not a repeated destructive action. Changed-owner/generation refusals also omit the replacement status from full/verbose replies; verbosity grants no extra scope. Actor-local dispatch exceptions still fail, conservatively leaving delivery, handling and effects unconfirmed; do not repeat automatically. Their optional follow-up starts at fresh owned inventory, not a copied stale Control id/generation. Raw causes remain Kernel-local even with verbose; oversized request targets are wholly omitted with explicit coverage under 16 KiB. This presentation does not prove closure.

kill accepts only a currently running owned generation, bypasses actor-local capacity, and creates no synthetic Control. There is no manual archive or removal. Session-start cleanup applies a 28-day age threshold and keeps the calling session's directory.

Long-lived services publish endpoint.json only when ready:

{
  "path": "/path/to/control.fifo",
  "type": "fifo",
  "ready_at": "2026-01-01T00:00:00.000Z",
  "run_instance_id": "generation-id"
}

Supported transports are Unix FIFO and Windows named pipe. Every actor-local Control uses the same portable envelope: action is at most 64 lowercase ASCII characters, serialized JSON input is at most 380 bytes, and the newline-terminated wire record is at most 512 bytes. Put larger data in a declared artifact/path and send only its bounded reference or instruction through Control. Delivery revalidates owner, generation, state, and process identity under the canonical lifecycle lock.

Run State

Owned state lives under one directory per Run, inside the logical Pi session that launched it:

~/.pi/agent/tmp/pi-actors/<session-hash>/<run>/

A Run is named per session as <recipe>-<ordinal> (or exactly as the caller requests); an exact name is refused once it has been used in that session. Names are reserved in the session's .names.json, which is not a Run directory. Launch requires an admitted current SDK session; there is no fallback storage route. A singleton service keeps one name per session, its Skill's, and restarts in the same directory.

Core files:

  • run.json — identity, owner, generation, captured Recipe, policy, process identity;
  • trace.jsonl — structured observations;
  • controls.jsonl — durable Controls and outcomes;
  • endpoint.json — recorded service endpoint; maintained services can record that their listener opened, not that it is still reachable;
  • steps.json — phase and progress, command/session provenance and complete-capture references;
  • stdout.txt / stderr.txt — the Run's output and errors, as produced (output is not redacted); an empty stream makes no file;
  • step-<N>.stdout.txt / step-<N>.stderr.txt — other steps of a multi-step Run (retries add .retry-<M>);
  • result.json, runner logs, and declared artifacts.

The runtime preserves owner filtering, process-identity verification, lifecycle locking, shutdown kill independent of actor-local Control capacity, terminal reconciliation, bounded captures, owned Pi sessions, path containment, and redaction. Trace/Control quotas do not constrain user-declared artifacts, repositories, media sources, complete captures, or actor-owned workload state. Restart clears generation-local Trace, Control, endpoint, execution, and terminal evidence.

A completion message is a short header — Run, state, exit code when it failed, and file paths — followed by the output text itself, so one reading is usually enough. Longer output is cut at a line the agent can continue from. Messages captured by earlier versions keep their original layout.

Actor Inspector

Open the owner-filtered TUI:

/actor-inspector

It presents actor instances through Recipe, Trace, and Status tabs, with source filtering, detail navigation, refresh, and generation-fenced Run Kill.

Skill Recipes

Useful entry points include:

  • project-work/repo-health
  • project-work/release-readiness
  • swarm/quorum-review
  • actors/file-write — save a step's output to your own path
  • music-player/playback — singleton controlled playback service
  • actors/resource-locker — optional controlled resource-lock service

Validate Recipes with:

npm run recipes:qa

Development

npm install
npm run build
npm test
npm run validate
npm run test:preservation

npm run validate runs the full test suite once, including every conformance suite with the same preload and execution flags. npm run conformance remains a standalone targeted subset; aggregate validation does not repeat it after the full suite. An invariant checks cohort inclusion and profile equivalence.

Tests normally mirror lib/<module>.ts as tests/<module>.test.ts, with related contract groups in that file. tests/invariants.test.ts checks the naming boundary and the explicit cross-domain/package exceptions; the preservation rules live in AGENTS.md.

Standard tests, preservation and conformance preload a fresh temporary default agent directory for each test-runner process, ignoring any operator-supplied agent path. These directories are retained rather than deleted on test-runner exit alone; individual fixtures keep their own explicit cleanup evidence. For direct launcher checks, use node --import ./tests/test-environment.mjs --experimental-strip-types --test ....

The atomic build produces the committed JavaScript modules and Skill resources in dist/ for npm and git installs. The package keeps its executable runner at scripts/async-runner.mjs, without a copy in dist/. npm run build:check checks the distributive without rewriting it. Pi can load a TypeScript extension entrypoint, but standalone Node processes cannot type-strip modules under node_modules; keeping compiled Run modules preserves process isolation without a runtime TypeScript loader.

See the documentation index, Run lifecycle, and Recipe library.

Project context: AGENTS.md · BACKLOG.md · CHANGELOG.md.

License

MIT