@llblab/pi-actors 0.19.10 → 0.19.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/AGENTS.md CHANGED
@@ -43,7 +43,7 @@
43
43
  - `Typed arg authoring`: Typed args support `string`, `path`, `int`, `number`, `bool`, and `enum(...)` plus two equivalent readability styles: metadata-first (`args` + `defaults` + simple `{name}` placeholders) for long command lines, and inline-first (`{name:type=default}` placeholders) for compact one-property templates | Trigger: Changing arg parsing, docs, schema generation, or registry serialization | Action: Preserve both styles, keep explicit `args` type declarations higher priority than inline placeholder types, and make breaking cleanup explicit when removing old arg shapes
44
44
  - `Template recipe graph`: The valid execution chain is `tool → template → recipe → run → template`; file-backed and co-located recipes are storage variants of that chain | Trigger: Adding registry bindings, recipes, docs, or runtime shortcuts | Action: Keep command templates synchronous and portable, use `async: true` as the detached run switch, require every recipe to own `template` directly, and reject cyclic shortcuts such as recipe-owned `tool`
45
45
  - `Layer boundary discipline`: Command-template evolution must be separated from template-recipe configuration and async-run lifecycle configuration | Trigger: Adding syntax, placeholders, imports, async controls, or docs | Action: Put portable execution graph semantics in `docs/command-templates.md`, recipe storage/import/default/reference behavior in `docs/template-recipes.md`, and detached lifecycle/state/IPC behavior in `docs/async-runs.md`; type imported recipes as command-template-shaped recipe definitions, not async-run instances
46
- - `Executable script recipes`: Recipe templates may point directly at executable helper scripts, including JavaScript `.mjs` files with shebangs; do not prefix such recipes with `node` unless the script is intentionally not executable | Trigger: Adding or editing script-backed recipes and docs | Action: Keep the script executable bit, call `{repo}/scripts/name.mjs ...` directly, and keep the standard library on one maintained wrapper per capability unless a second wrapper has a concrete platform reason
46
+ - `Executable script recipes`: Recipe templates may point directly at executable helper scripts, including JavaScript `.mjs` files with shebangs; do not prefix such recipes with `node` unless the script is intentionally not executable | Trigger: Adding or editing script-backed recipes and docs | Action: Keep the script executable bit, call `{repo}/scripts/name.mjs ...` directly, keep the standard library on one maintained wrapper per capability unless a second wrapper has a concrete platform reason, and ensure installed npm script entrypoints do not import `.ts` files from under `node_modules` through Node native type stripping
47
47
  - `Registry safety boundaries`: Tool definitions use `template`, not `script`, and built-in/core tool names must not be shadowed | Trigger: Loading/editing persisted config or registration logic | Action: Reject legacy `script` entries explicitly, avoid silent user-config rewrites outside the repo, and keep conflict checks before persistence/runtime registration
48
48
  - `Async run observability`: Ambient triangles count active async work units across the visible run tree: each running async run contributes at least one triangle, reported active parallel command/subagent branches contribute the visible branch count when greater than one, and descendant `pi -p` subagent processes are folded in so coordinator-plus-workers scenarios expand beyond a single coordinator marker. Event-driven terminal/outbox watchers should initiate follow-up for unhandled terminal completion/failure states, failed or in-flight `command.done` branch completions, and coordinator-bound script-authored messages with bounded body previews; actor `message` is the explicit coordinator-to-run command channel paired with these upward events. Do not restore busy-polling loops, sleep-then-status smoke examples, duplicate follow-ups for final successful leaf commands, or duplicate follow-ups for `cancel`, `kill`, or control-stop actions already handled by synchronous tool results. | Trigger: Changing async run UI, notifications, actor-message routing, or smoke-test interpretation | Action: Preserve branch-aware triangles from `progress.activeSubagents`, runtime-inferred branch bubbling for packaged fanout completion, process-tree expansion for coordinator-launched workers, terminal notifications as event-driven behavior, and docs/examples that teach reactive run→coordinator→message loops before sleep-polling patterns.
49
49
  - `Communication direction`: The design target is an organic universal message layer across sync tasks, async runs, branches, tools, and coordinators. Breaking changes are allowed to compress concepts, remove accidental duplication, and make duplex communication symmetric where the domain is symmetric. | Trigger: Designing APIs or recipes that communicate | Action: Prefer a concentrated actor/message protocol (`spawn`, `message`, `inspect`, addressed endpoints, typed message envelopes, mailbox accepts/emits) over exposing FIFO/outbox/status mechanics directly; use one envelope for upward, downward, lateral, parent/branch, and branch/parent messages; absorb runtime async primitives into actor API instead of preserving parallel public concepts.
package/BACKLOG.md CHANGED
@@ -8,10 +8,13 @@
8
8
  - Goal: Continue evolving actor communication without adding a second public messaging model.
9
9
  - Direction:
10
10
  - Evaluate whether room storage/routing should remain built into the tool adapter or move behind a dedicated non-LLM communication actor recipe/script, possibly singleton-scoped. Preserve the same public `room:<run>` address and envelope either way.
11
+ - Treat the next backend decision as an evidence-backed experiment, not a rewrite: stress a real room/direct-message workload, compare the current file-backed adapter with a thin communication actor/helper, and record the decision.
11
12
  - Consider reducing direct file-backed state where it improves coherence: model room/roster state as actor-owned data structures served by helper scripts/actors, with files retained only for durable snapshots, recovery, artifacts, or audit logs.
12
- - Further storage changes should preserve the current burst/read/concurrency safeguards: branch communication snapshot writes are debounced, root snapshots stay current, roster files are not rewritten during bursts when only `last_seen` changes, room status inspection does not parse full timelines, and branch-local inbox append/status rewrites are lock-guarded.
13
+ - Further storage changes should preserve the current burst/read/concurrency safeguards: branch communication snapshot writes are debounced, root snapshots stay current, roster files are not rewritten during bursts when only `last_seen` changes, room status inspection does not parse full timelines, branch-local inbox append/status rewrites are lock-guarded, and legacy no-ID branch inbox records can be claimed exactly once.
14
+ - Prevent monolith drift: `actor-rooms.ts` may remain a thin adapter, but growing routing policy, subscription loops, fanout policy, or long-lived state ownership should move behind a focused communication helper/actor rather than accumulating in the tool adapter.
13
15
  - Exit:
14
16
  - Any backend/storage change preserves existing `spawn` / `message` / `inspect` semantics and room address compatibility.
17
+ - A short decision note or changelog entry explains why the room backend stayed file-backed or moved behind a communication actor/helper.
15
18
 
16
19
  ### Graceful Actor Retirement
17
20
 
@@ -27,6 +30,18 @@
27
30
  - A packaged coordinator recipe can launch worker actors, complete its coordination duties, and shut itself down automatically after the worker tree reaches terminal state.
28
31
  - Persistent services and implementer actors remain alive unless their recipe explicitly opts into retirement.
29
32
 
33
+ ### Coordinator Strategy Boundary
34
+
35
+ - Priority: Medium.
36
+ - Goal: Keep the generic coordinator from becoming a second overloaded monolith as room/direct-message workflows mature.
37
+ - Direction:
38
+ - Split only at real pressure points: branch inbox claim/finalize helpers, participant execution, room transcript synthesis, and mode strategies are likely seams, but avoid cosmetic module churn.
39
+ - Preserve the current principle that the locker stays generic/thin and all orchestration policy stays in coordinator strategy code or recipe composition.
40
+ - Prefer reusable helper modules or small scripts only when at least two packaged workflows need the same behavior.
41
+ - Exit:
42
+ - Adding a new coordinator mode or packaged multi-agent workflow does not require editing unrelated mode logic.
43
+ - Existing room-swarm, locker, and direct-branch-message tests still cover the extracted seams.
44
+
30
45
  ### Consensus-First Build Recipe
31
46
 
32
47
  - Priority: Medium.
@@ -42,6 +57,18 @@
42
57
  - A packaged recipe can reproduce the interactive-music-instrument workflow shape for another single-artifact task without copying the demo script.
43
58
  - Docs and skills point agents to the packaged recipe and explain when to choose it over a free-form room swarm.
44
59
 
60
+ ### Actor OS Scenario Smoke Matrix
61
+
62
+ - Priority: Medium.
63
+ - Goal: Convert the 0.19.x actor-communication hardening into repeatable end-to-end scenario checks instead of relying on ad hoc demos.
64
+ - Direction:
65
+ - Cover one scenario each for shared room coordination, direct branch work delivery, branch inbox claim/handle/fail transitions, inspector navigation, recipe context injection, recipe persistence suggestion, and opt-in retirement candidate detection.
66
+ - Keep scenarios local-first and bounded: fake `pi`/models where possible, no external services, no long sleeps, no broad golden transcripts.
67
+ - Prefer packaged recipes and public `spawn` / `message` / `inspect` calls so the smoke matrix exercises the same surface agents use.
68
+ - Exit:
69
+ - A single validation command or documented test group verifies the actor OS behaviors that made 0.19.x production-useful.
70
+ - The smoke matrix catches regressions in actor communication, recipe memory, and observability without requiring a manual swarm demo.
71
+
45
72
  ### Persistent Backlog Implementer Workflow
46
73
 
47
74
  - Priority: Medium.
@@ -84,10 +111,22 @@
84
111
  - Add nested recipe directories only after flat `recipes/*.json` discovery semantics are stable.
85
112
  - Keep same-id priority and invalid-blocking behavior explicit if nested ids are introduced.
86
113
 
114
+ ### Actor Recipe Feedback Loop
115
+
116
+ - Priority: Low.
117
+ - Goal: Turn actor recipe-context awareness into a practical improvement loop for packaged recipes and operator-owned recipe memory.
118
+ - Direction:
119
+ - After real multi-agent runs, capture whether child actors report that recipe/import/mailbox/role boundaries fit the task.
120
+ - Keep the loop advisory and operator-gated: feedback may suggest recipe edits or copying into `~/.pi/agent/recipes`, but must not auto-save or rewrite durable recipes without confirmation.
121
+ - Prefer small recipe/readme/skill refinements over adding scenario catalogs; recurring patterns should become packaged recipes only after repeated use.
122
+ - Exit:
123
+ - At least one real run produces recipe-boundary feedback that is either applied to a recipe/docs change or explicitly rejected with rationale.
124
+
87
125
  ### Recipe Usage Telemetry Evolution
88
126
 
89
127
  - Priority: Low.
90
128
  - Goal: Improve long-term operator insight into recipe usefulness without making telemetry noisy.
91
129
  - Direction:
92
130
  - Consider sidecar stats sync/backup policy after inline user-owned `usage.calls` / `usage.last_called` proves useful.
131
+ - Consider an operator-approved recipe promotion workflow that turns successful package/ad hoc/direct spawn suggestions into a reviewed `~/.pi/agent/recipes` entry with provenance and diff, without auto-saving.
93
132
  - Do not add failure counters as primary usefulness evidence unless there is a strong operator-facing need.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.19.11: Installed Async Runner Hotfix
4
+
5
+ - `[Async Runs]` Fixed installed npm package async recipe launches on Node 22 by avoiding direct runtime imports of raw `.ts` files from under `node_modules` in `scripts/async-runner.mjs`. Installed runners now copy the package `lib` sources into the run state before importing them, keeping Node native type stripping outside the blocked `node_modules` path.
6
+ - `[Scripts]` Applied the same installed-package import guard to `scripts/validate-recipe.mjs`, so the packaged recipe validator works when invoked from an installed `@llblab/pi-actors` package.
7
+ - `[Tests]` Added installed-package script smoke coverage that copies `lib`/`scripts` under a temporary `node_modules/@llblab/pi-actors` path and verifies both async runner execution and recipe validation avoid `ERR_UNSUPPORTED_NODE_MODULES_TYPE_STRIPPING`.
8
+ - `[Package]` Bumped package metadata, lockfile metadata, and packaged skill metadata to `0.19.11` for the hotfix release.
9
+
3
10
  ## 0.19.10: Legacy Branch Message Claim IDs
4
11
 
5
12
  - `[Branch Messages]` Coordinator claim handling now assigns IDs to older/manual queued branch inbox entries that lack `id`, so injected direct messages can still transition to `handled` or `failed` and do not repeat forever.
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@llblab/pi-actors",
3
- "version": "0.19.10",
3
+ "version": "0.19.11",
4
4
  "private": false,
5
- "description": "Actor runtime and orchestrator for agent-managed local processes",
5
+ "description": "Local Actor Kernel for Pi",
6
6
  "keywords": [
7
7
  "pi-package",
8
8
  "pi-extension",
@@ -11,18 +11,42 @@
11
11
  * Keep orchestration policy out of this file.
12
12
  */
13
13
 
14
- import { appendFileSync, readFileSync } from "node:fs";
15
- import { join } from "node:path";
14
+ import { appendFileSync, cpSync, existsSync, readFileSync } from "node:fs";
15
+ import { dirname, join } from "node:path";
16
+ import { fileURLToPath, pathToFileURL } from "node:url";
16
17
 
17
18
  const stateDir = process.argv[2];
18
19
  if (!stateDir) {
19
20
  console.error("missing state dir");
20
21
  process.exit(1);
21
22
  }
22
- const { executeRegisteredTool } = await import("../lib/execution.ts");
23
- const { execCommandTemplate } = await import("../lib/command-templates.ts");
24
- const { appendRecipeContextToPiArgs } = await import("../lib/actor-recipe-context.ts");
25
- const { writeJsonAtomic } = await import("../lib/file-state.ts");
23
+
24
+ function scriptFile() {
25
+ return fileURLToPath(import.meta.url);
26
+ }
27
+
28
+ function isUnderNodeModules(file) {
29
+ return /[/\\]node_modules[/\\]/.test(file);
30
+ }
31
+
32
+ function prepareTypeStripImportRoot() {
33
+ const packageRoot = dirname(dirname(scriptFile()));
34
+ const sourceLib = join(packageRoot, "lib");
35
+ if (!isUnderNodeModules(packageRoot)) return sourceLib;
36
+ const copiedLib = join(stateDir, ".type-strip-lib");
37
+ if (!existsSync(copiedLib)) cpSync(sourceLib, copiedLib, { recursive: true });
38
+ return copiedLib;
39
+ }
40
+
41
+ const typeStripImportRoot = prepareTypeStripImportRoot();
42
+ async function importLib(name) {
43
+ return import(pathToFileURL(join(typeStripImportRoot, `${name}.ts`)).href);
44
+ }
45
+
46
+ const { executeRegisteredTool } = await importLib("execution");
47
+ const { execCommandTemplate } = await importLib("command-templates");
48
+ const { appendRecipeContextToPiArgs } = await importLib("actor-recipe-context");
49
+ const { writeJsonAtomic } = await importLib("file-state");
26
50
  const runPath = join(stateDir, "run.json");
27
51
  const progressPath = join(stateDir, "progress.json");
28
52
  const resultPath = join(stateDir, "result.json");
@@ -1,9 +1,30 @@
1
1
  #!/usr/bin/env -S node --experimental-strip-types
2
- import { existsSync, readdirSync, statSync } from "node:fs";
3
- import { homedir } from "node:os";
4
- import { resolve } from "node:path";
2
+ import { cpSync, existsSync, mkdtempSync, readdirSync, statSync } from "node:fs";
3
+ import { homedir, tmpdir } from "node:os";
4
+ import { dirname, join, resolve } from "node:path";
5
+ import { fileURLToPath, pathToFileURL } from "node:url";
5
6
 
6
- import { readResolvedRecipeConfig } from "../lib/recipe-references.ts";
7
+ function scriptFile() {
8
+ return fileURLToPath(import.meta.url);
9
+ }
10
+
11
+ function isUnderNodeModules(file) {
12
+ return /[/\\]node_modules[/\\]/.test(file);
13
+ }
14
+
15
+ function prepareTypeStripImportRoot() {
16
+ const packageRoot = dirname(dirname(scriptFile()));
17
+ const sourceLib = join(packageRoot, "lib");
18
+ if (!isUnderNodeModules(packageRoot)) return sourceLib;
19
+ const copiedLib = join(mkdtempSync(join(tmpdir(), "pi-actors-validate-lib-")), "lib");
20
+ cpSync(sourceLib, copiedLib, { recursive: true });
21
+ return copiedLib;
22
+ }
23
+
24
+ const typeStripImportRoot = prepareTypeStripImportRoot();
25
+ const { readResolvedRecipeConfig } = await import(
26
+ pathToFileURL(join(typeStripImportRoot, "recipe-references.ts")).href
27
+ );
7
28
 
8
29
  function usage() {
9
30
  console.error(`Usage:
@@ -2,7 +2,7 @@
2
2
  name: actors
3
3
  description: Highest-density practical guide for pi-actors. Read this skill whenever prompt and tools are not enough for spawn, message, inspect, actor runs, tools, recipes, command templates, async lifecycle, mailboxes, artifacts, and local orchestration mechanics.
4
4
  metadata:
5
- version: 0.19.10
5
+ version: 0.19.11
6
6
  ---
7
7
 
8
8
  # Actors (pi-actors)
@@ -2,7 +2,7 @@
2
2
  name: swarm
3
3
  description: Subagent orchestration with scoped locks and quorum consensus. Use for multi-model review, parallel scoped work, delegated audit, and coordinated subagent execution.
4
4
  metadata:
5
- version: 0.19.10
5
+ version: 0.19.11
6
6
  ---
7
7
 
8
8
  # Swarm