@llblab/pi-actors 0.16.4 → 0.17.1

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/README.md CHANGED
@@ -1,206 +1,178 @@
1
1
  # pi-actors
2
2
 
3
- > Actor runtime and orchestrator for agent-managed local processes.
3
+ > Local Actor Kernel for Pi
4
4
 
5
- [<img alt="Actors*" src="banner.jpg" />](https://github.com/llblab/pi-actors "pi-actors")
5
+ ![Actors](./banner.jpg)
6
6
 
7
- `pi-actors` turns local programs, scripts, services, recipes, and long-running processes into addressable actors that agents can start, message, inspect, and compose. A music player, a sub-agent fanout, a repo-health pipeline, or any trusted local process can become an actor when it has a template-backed launch path, a mailbox contract, and observable runtime state.
7
+ `pi-actors` turns trusted local programs, scripts, recipes, services, pipelines, and sub-agents into addressable actors that agents can spawn, message, inspect, and compose.
8
8
 
9
- The persistent tool registry is still useful: it lets agents keep durable operational muscle memory for trusted local commands and wrappers. But the project lens is broader than stored tools. `pi-actors` is a local-first orchestration runtime for wrapping capabilities as agent-managed entities with explicit interfaces.
10
-
11
- ## Start Here
12
-
13
- - [Project Context](./AGENTS.md)
14
- - [Open Backlog](./BACKLOG.md)
15
- - [Changelog](./CHANGELOG.md)
16
- - [Documentation](./docs/README.md)
17
- - [Actors skill](./skills/actors/SKILL.md) — dense agent-facing reference for operating the extension
18
- - [Swarm skill](./skills/swarm/SKILL.md) — multi-agent methodology, strategies, standards, and portable examples for actor-backed swarms
19
- - [Swarm MAWP notes](./skills/swarm/references/development-swarm.md) — optional small-team development swarm reference
20
-
21
- ## What It Is
22
-
23
- `pi-actors` is the runtime layer that lets a pi agent turn a local capability into a controllable actor:
9
+ It is not just a command registry. A tool is a verb. An actor is a noun with time: address, lifecycle, state, logs, mailbox, artifacts, and an interaction contract.
24
10
 
25
11
  ```text
26
- program/process/service
12
+ program / process / service
27
13
  → command template
28
14
  → actor recipe
29
15
  → spawn
30
- addressable actor
16
+ run:<id>
31
17
  → message / inspect / artifacts
32
18
  ```
33
19
 
34
- An actor can be:
35
-
36
- - A sub-agent running `pi -p` in a clean context.
37
- - A background music player controlled by `player.next` or `player.pause` messages.
38
- - A validation or repo-health pipeline that reports completion and artifacts.
39
- - A parallel quorum review with branch-level progress.
40
- - Any trusted local process with a launch template and a useful control surface.
20
+ ## Core Contract
41
21
 
42
- The key move is not just “register a command.” It is to wrap a process in an agent-readable contract:
22
+ `pi-actors` compresses local agent orchestration to three durable verbs:
43
23
 
44
- - **Launch**: `spawn` starts the actor from a template or recipe.
45
- - **Interface**: `mailbox` declares accepted and emitted message types.
46
- - **Control**: `message` sends typed envelopes to runs, branches, tools, or the coordinator.
47
- - **Observation**: `inspect` reads status, logs, messages, mailbox metadata, files, and artifacts intentionally.
48
- - **Persistence**: `artifacts` and state files make outcomes durable.
49
- - **Memory**: `~/.pi/agent/recipes/*.json` stores reusable actor-control wrappers across sessions.
24
+ ```text
25
+ spawn create an addressable actor
26
+ message send one typed envelope to one address
27
+ inspect intentionally read state, logs, messages, contracts, or artifacts
28
+ ```
50
29
 
51
- ## Key Features
30
+ Everything else is an adapter until proven otherwise.
52
31
 
53
- - **Actor Runtime**: Starts local templates and recipes as addressable `run:<id>` actors with state, logs, message mailboxes, cancellation, and artifacts.
54
- - **Agent-Managed Processes**: Wraps sub-agents, media players, pipelines, diagnostics, and other local programs as controllable entities instead of one-off commands.
55
- - **Message-Oriented Control**: Uses `spawn`, `message`, and `inspect` as the public coordination vocabulary for start, control, and observation.
56
- - **Mailbox Contracts**: Lets recipes declare what messages they accept and emit, so agents can discover how to interact with an actor.
57
- - **Actor Tool Registry**: Stores persistent actor-control tools as recipe files in `~/.pi/agent/recipes/*.json` and registers them automatically on session start.
58
- - **Command Template Substrate**: Keeps process launch portable with named placeholders, typed args, defaults, sequences, guarded nodes, retries, failure policy, and `parallel: true` fanout.
59
- - **Composable Actor Recipes**: Stores reusable recipe JSON under `~/.pi/agent/recipes/*.json`; recipes can import other recipes, reuse defaults, declare artifacts, and opt into detached actor lifecycle with `async: true`.
60
- - **Coordinator-Scoped Observability**: Shows ambient triangles for active actor runs and sends compact completion or request-for-attention follow-ups only to the launching coordinator.
61
- - **Bounded Context Impact**: Returns compact output by default, truncates oversized stdout, and keeps full logs/artifacts in files for intentional inspection.
62
- - **Local-First Tool Memory**: Still lets agents create durable semantic tools from trusted commands so they do not repeatedly reconstruct shell invocations.
32
+ Use `spawn` when work may outlive the current turn. Use `message` when the actor should be steered rather than restarted. Use `inspect` at decision points, after actor follow-ups, or during diagnosis. Do not build polling loops as the default coordination pattern.
63
33
 
64
34
  ## Install
65
35
 
66
- From npm:
67
-
68
36
  ```bash
69
37
  pi install npm:@llblab/pi-actors
70
38
  ```
71
39
 
72
- From git:
40
+ Or from git:
73
41
 
74
42
  ```bash
75
43
  pi install git:github.com/llblab/pi-actors
76
44
  ```
77
45
 
78
- ## Registry Migration
46
+ ## Address Surface
79
47
 
80
- `pi-actors` now reads persistent actor-control tools from:
48
+ Actors and coordination endpoints are addressed with compact route strings:
81
49
 
82
50
  ```text
83
- ~/.pi/agent/recipes/*.json
51
+ run:<id> one detached actor run
52
+ branch:<run>/<branch> branch-local actor endpoint
53
+ room:<run> shared run-local task room
54
+ coordinator launching coordinator attention path
55
+ session: current session actor surface
56
+ session:all cross-session inventory surface
57
+ tool:<name> executable registered tool
84
58
  ```
85
59
 
86
- That directory is the operator-managed tool set: user recipe files there become tools by default unless they set `tool: false`. Packaged recipes are the lower-priority standard library of declarative actor components and opt into tools with `tool: true`.
87
-
88
- If `~/.pi/agent/actors-tools.json` exists from an older release, pi-actors treats it as legacy compatibility input, migrates entries into recipe files when possible, writes a migration report, and archives the legacy file only when migration is clean.
60
+ Actor messages use one envelope shape:
89
61
 
90
- ## Mental Model
91
-
92
- `pi-actors` separates launch mechanics from actor semantics:
93
-
94
- ```text
95
- command template = how to start work
96
- actor recipe = saved actor definition
97
- spawn = create actor instance
98
- message = connect/control actors
99
- inspect = observe intentionally
100
- artifacts = persist outcomes
101
- mailbox = declare interaction contract
62
+ ```json
63
+ {
64
+ "to": "run:review",
65
+ "from": "coordinator",
66
+ "type": "control.continue",
67
+ "summary": "Continue after checkpoint",
68
+ "body": "continue",
69
+ "reply_to": "msg_123",
70
+ "correlation_id": "task_456",
71
+ "metadata": {}
72
+ }
102
73
  ```
103
74
 
104
- - A **command** is one concrete local process.
105
- - A **command template** is the reusable launch shape for that process, with named placeholders.
106
- - An **actor recipe** is saved JSON containing a template, defaults, imports, mailbox metadata, artifacts, and optional detached lifecycle.
107
- - A **registered tool** gives a template or actor recipe a stable agent-facing name.
108
- - A **run actor** is one execution instance with state, logs, actor messages, mailbox metadata, status, cancellation, and kill control.
109
-
110
- The template remains the execution substrate. The recipe is the actor definition. `async: true` opts into detached actor lifecycle. `spawn` creates actors, `message` connects or controls them, and `inspect` observes them without teaching agents to poll blindly.
111
-
112
- ## Operator Onboarding
75
+ Routing is inferred from `to`, actor ownership, and runtime policy. Recipes should expose semantic message types, not transport knobs.
113
76
 
114
- Start with foreground templates when the work is short and deterministic:
77
+ ## Golden Path
115
78
 
116
- ```text
117
- register_tool name=lint_docs description="Lint docs" template="npm run lint:docs"
118
- ```
79
+ Create a reusable async actor recipe in the user recipe root:
119
80
 
120
- Move to actor recipes when work is long-running, parallel, service-like, or agentic:
81
+ ```bash
82
+ mkdir -p ~/.pi/agent/recipes
121
83
 
122
- ```json
84
+ cat > ~/.pi/agent/recipes/docs_review.json <<'JSON'
123
85
  {
124
- "name": "docs_review",
86
+ "description": "Start an async docs review actor",
125
87
  "async": true,
126
88
  "args": ["scope:path", "model:string"],
127
- "defaults": {},
128
89
  "mailbox": {
129
- "accepts": ["control.stop"],
90
+ "accepts": ["control.stop", "control.continue"],
130
91
  "emits": ["review.completed", "run.failed"]
131
92
  },
132
93
  "template": "pi -p --model {model} --no-tools \"Review {scope} for unclear actor-runtime onboarding. Return concise findings.\""
133
94
  }
95
+ JSON
134
96
  ```
135
97
 
136
- Expose a reusable actor recipe as a normal capability:
98
+ Because it lives under `~/.pi/agent/recipes/`, the file becomes a persistent agent tool by location. The filename is the tool id.
99
+
100
+ Start it:
137
101
 
138
102
  ```text
139
- register_tool name=docs_review description="Start an async docs review actor" template="docs_review" args="scope:path,model:string"
103
+ docs_review scope="README.md" model="current-review-model" run_id=docs_review
140
104
  ```
141
105
 
142
- `Task` is the user's work item. `Template` is the execution graph. `Actor recipe` is saved JSON. `Run` is one actor instance with status, logs, messages, cancellation, artifacts, and ambient triangles.
106
+ Inspect only when there is a reason:
143
107
 
144
- ## Compose Recipes With Imports
145
-
146
- Recipes can import other recipe files and reuse them as named nodes. This keeps reusable steps small while letting a parent recipe decide whether the combined graph runs foreground or as one detached run actor.
108
+ ```text
109
+ inspect target=run:docs_review view=status
110
+ inspect target=run:docs_review view=tail lines=80
111
+ inspect target=run:docs_review view=messages
112
+ inspect target=run:docs_review view=mailbox
113
+ ```
147
114
 
148
- `review-one.json`:
115
+ Steer it through messages:
149
116
 
150
- ```json
151
- {
152
- "name": "review-one",
153
- "args": ["scope:string", "model:string"],
154
- "defaults": {},
155
- "template": "pi -p --model {model} --no-tools \"Review {scope}\""
156
- }
117
+ ```text
118
+ message to=run:docs_review type=control.continue body=continue
119
+ message to=run:docs_review type=control.stop body=stop
157
120
  ```
158
121
 
159
- `review-pair.json`:
122
+ ## Actor Rooms
160
123
 
161
- ```json
162
- {
163
- "name": "review-pair",
164
- "async": true,
165
- "imports": {
166
- "review": "review-one.json"
167
- },
168
- "parallel": true,
169
- "failure": "branch",
170
- "template": [
171
- { "name": "review", "values": { "scope": "README.md" } },
172
- { "name": "review", "values": { "scope": "docs/template-recipes.md" } }
173
- ]
174
- }
124
+ Every spawned run can have a shared room at `room:<run>`. A room is not a broker and not a chat app. It is a run-local coordination surface: append-only timeline, compact roster, member discovery, and previews.
125
+
126
+ Actors can join, post, leave, and discover peers:
127
+
128
+ ```text
129
+ message \
130
+ to=room:review \
131
+ from=branch:review/security \
132
+ type=actor.join \
133
+ summary="Security reviewer joined" \
134
+ body='{"role":"reviewer","caps":["security-review"],"claim":"Review auth boundary risks"}'
175
135
  ```
176
136
 
177
- Register only the parent when that is the operator-facing capability:
137
+ Inspect the room intentionally:
178
138
 
179
139
  ```text
180
- register_tool name=review_pair \
181
- description="Start a parallel async docs review" \
182
- template="review-pair.json"
140
+ inspect target=room:review view=status
141
+ inspect target=room:review view=previews
142
+ inspect target=room:review view=roster
143
+ inspect target=room:review view=contacts
144
+ inspect target=room:review view=messages
183
145
  ```
184
146
 
185
- Imported recipes are recipe definitions, not nested run actors. The parent recipe's `async: true` creates one run actor with one state dir; imported recipes contribute command-template graph, args, defaults, and values.
147
+ Room posts require a same-run sender, so unrelated runs do not pollute the roster. Direct messages and room messages use the same envelope; only the address changes.
186
148
 
187
- ## Register Actor-Control Tools
149
+ ## Registry Model
188
150
 
189
- `register_tool` lists, registers, updates, or deletes persistent actor-control tools. Call it without arguments to list the current registry. These tools are convenient handles for creating or invoking actors, not the whole runtime model.
151
+ The persistent tool surface is file-discovered:
190
152
 
191
- ### Local command: transcription
153
+ ```text
154
+ ~/.pi/agent/recipes/*.json
155
+ ```
192
156
 
193
- `pi-actors` is also useful for exposing stable local commands as normal tools. For example, register an STT command:
157
+ That directory is operator-managed executable memory.
158
+
159
+ Rules:
160
+
161
+ - User recipes in `~/.pi/agent/recipes/` are tools by location;
162
+ - Recipe filenames define tool ids;
163
+ - User recipes override same-name lower-priority recipes;
164
+ - Packaged recipes are standard-library components, not automatically installed operator policy;
165
+ - `register_tool` creates, updates, lists, or deletes user recipe files through the normal agent interface.
166
+
167
+ Example foreground tool:
194
168
 
195
169
  ```text
196
- register_tool name=transcribe \
170
+ register_tool name=transcribe_audio \
197
171
  description="Transcribe a local audio file" \
198
- template="/path/to/stt --file {file} --lang {lang=ru}"
172
+ template="~/bin/transcribe {file:path} {lang=ru} {model:string}"
199
173
  ```
200
174
 
201
- ### Template recipe
202
-
203
- For reusable actor workflows, keep the large template and mailbox contract in a recipe file and register a small tool:
175
+ Example recipe-backed tool:
204
176
 
205
177
  ```text
206
178
  register_tool name=docs_review \
@@ -209,183 +181,107 @@ register_tool name=docs_review \
209
181
  args="scope:path,model:string"
210
182
  ```
211
183
 
212
- If the recipe file contains `async: true`, calling `docs_review` starts a detached run and returns metadata immediately. If `async` is omitted or false, the same recipe runs foreground and returns normal tool output.
213
-
214
- When keeping metadata and the recipe body together is clearer, `register_tool` writes a complete user recipe file:
184
+ Inspect the discovered registry:
215
185
 
216
- ```json
217
- {
218
- "description": "Start an async docs review",
219
- "tool": true,
220
- "async": true,
221
- "args": ["scope:path", "model:string"],
222
- "template": "pi -p --model {model} --tools read,bash \"Review {scope}\""
223
- }
186
+ ```text
187
+ inspect target=recipes view=status
188
+ inspect target=recipes view=summary verbose=true
224
189
  ```
225
190
 
226
- The filename is the recipe id/tool name, `async: true` selects detached run mode, and `template` remains the executable body.
191
+ ## Command Templates
227
192
 
228
- ### Sub-agent
193
+ A command template is the portable launch substrate. It can be a string, a sequence, or a composed graph.
229
194
 
230
- ```text
231
- register_tool name=call_subagent \
232
- description="Run pi as a non-interactive sub-agent" \
233
- template="pi -p --model {model} --no-tools {prompt}" args="prompt:string,model:string"
234
- ```
195
+ Templates support:
235
196
 
236
- Use `update=true` to overwrite an existing tool. Omit `template` during update to keep the previous template:
197
+ - Named placeholders: `{file}`, `{model}`, `{prompt}`;
198
+ - Compact types: `string`, `path`, `int`, `number`, `bool`, `enum(a,b)`;
199
+ - Defaults: `{lang=ru}`, `{dry_run:bool=true}`;
200
+ - Fallback and small ternary forms;
201
+ - Sequences with stdin flow;
202
+ - Parallel nodes;
203
+ - Retries, recovery, failure policy, delays, and guarded execution;
204
+ - Async run values such as `{run_id}`, `{state_dir}`, `{actor_address}`, `{default_room}`, and `{communication_file}`.
237
205
 
238
- ```text
239
- register_tool name=call_subagent \
240
- description="Run a focused pi sub-agent without tools" \
241
- update=true
242
- ```
206
+ The template owns execution shape. The recipe owns saved metadata, defaults, imports, mailbox, and artifacts. The run actor owns detached lifecycle, state, messages, cancellation, and inspection.
243
207
 
244
- Delete a tool:
208
+ ## Recipe Library
245
209
 
246
- ```text
247
- register_tool name=call_subagent template=null
248
- ```
210
+ Packaged recipes live under `recipes/` and helper scripts live under `scripts/`.
249
211
 
250
- ## Resulting Recipe Files
212
+ The library includes:
251
213
 
252
- The commands above persist files under `~/.pi/agent/recipes/`. Tool names come from recipe filenames. Stored recipes keep `template` last so flags and metadata are read before executable content:
214
+ - Sub-agent launchers;
215
+ - Review, critic, planner, verifier, merger, judge, normalizer, and artifact atoms;
216
+ - Quorum and lens-style pipelines;
217
+ - Repo-health, release-summary, research-synthesis, development-tasking, docs-maintenance, and room-swarm pipelines;
218
+ - Coordinator-locker and actor-message utilities;
219
+ - Local music-player actor recipe.
253
220
 
254
- ```json
255
- {
256
- "description": "Transcribe a local audio file",
257
- "tool": true,
258
- "template": "/path/to/stt --file {file} --lang {lang=ru}"
259
- }
260
- ```
221
+ Packaged recipes are building blocks. Copy them into `~/.pi/agent/recipes/` or register tools that point at them when they should become durable operator-facing capabilities.
261
222
 
262
- ```json
263
- {
264
- "description": "Run pi as a non-interactive sub-agent",
265
- "tool": true,
266
- "args": ["prompt:string", "model:string"],
267
- "template": "pi -p --model {model} --no-tools {prompt}"
268
- }
269
- ```
223
+ ## When To Use What
270
224
 
271
- The recipe directory is the durable actor-tool registry. `register_tool` is the interactive API; recipe files are the persisted state loaded on future sessions.
225
+ Use a foreground registered tool when the work is short, bounded, and does not need lifecycle.
272
226
 
273
- ## Manage Actors
227
+ Use an async recipe or `spawn` when the work is long-running, service-like, parallel, agentic, artifact-producing, or needs later control.
274
228
 
275
- Use `spawn` when a command template, service, pipeline, or recipe may outlive the current turn. It starts the work now as an addressable actor, returns immediately with state metadata, and keeps ordinary files under `~/.pi/agent/tmp/pi-actors/runs/<run>` for later inspection.
229
+ Use `room:<run>` when multiple actors in the same run need shared context, roster discovery, or group-visible progress.
276
230
 
277
- Start from an inline template as an addressable run actor:
231
+ Use artifacts when outputs should survive context compression.
278
232
 
279
- ```json
280
- {
281
- "as": "run:docs-review",
282
- "template": "pi -p --model {model} --no-tools {prompt}",
283
- "values": {
284
- "prompt": "Review docs/spec.md for contradictions.",
285
- "model": "current-review-model"
286
- }
287
- }
288
- ```
233
+ Use mailbox declarations when an actor has a stable conversational surface.
289
234
 
290
- Do not check it on a timer. Let follow-up actor messages arrive from the run, then react to a run-local request or redirect a long-lived recipe without polling/restarting it:
235
+ ## Safety Boundary
291
236
 
292
- ```json
293
- { "to": "run:docs-review", "type": "control.continue", "body": "continue" }
294
- ```
237
+ `pi-actors` is local-first, not sandbox-first.
295
238
 
296
- Read recent actor messages or logs only after a follow-up asks for inspection, at a real decision point, or during diagnosis:
239
+ Commands execute directly without shell evaluation where possible, but trusted executables still run with the same system permissions as Pi. Only register commands, scripts, recipes, and paths you trust.
297
240
 
298
- ```json
299
- { "target": "run:docs-review", "view": "tail", "lines": "80" }
300
- ```
241
+ High-risk templates such as shells, interpreter eval modes, and broad filesystem mutation may surface warnings, but the runtime is not a security boundary.
301
242
 
302
- Reusable local recipes live in `~/.pi/agent/recipes/*.json`; recipe tools honor each file's `async` flag. Use `spawn` for explicit detached starts from a file or inline template, and `inspect target=coordinator view=runs status=running`, `inspect target=session:<id> view=runs status=running`, or `inspect target=session:all view=runs` for explicit inventory/diagnosis. List output includes `tool` and `recipe` when the launcher recorded that source context.
243
+ Prefer:
303
244
 
304
- ## Recipe Library
245
+ - Narrow commands;
246
+ - Explicit paths;
247
+ - Typed args;
248
+ - Bounded timeouts for bounded work;
249
+ - Explicit tool allowlists for sub-agents;
250
+ - Deterministic utility recipes for filesystem writes;
251
+ - Human approval for destructive or external side effects.
305
252
 
306
- Packaged standard recipes live under root `recipes/` with helper scripts under root `scripts/`. They are reusable library definitions, not automatically installed operator policy.
253
+ ## Non-Goals
307
254
 
308
- The subagent component recipes start non-interactive pi subagents as detached run actors or compose component recipes into higher-level coordinator pipelines. Use the no-tools recipe for the safest default, the explicit-tool variant when a bounded tool allowlist is needed, or the prompts fanout parent recipe to see imported subagent recipe nodes composed into one run actor:
255
+ `pi-actors` is NOT:
309
256
 
310
- ```text
311
- register_tool name=subagent_prompt \
312
- description="Start an async no-tools pi subagent" \
313
- template="subagent-prompt.json"
314
-
315
- register_tool name=subagent_tools \
316
- description="Start an async pi subagent with an explicit tool allowlist" \
317
- template="subagent-tools.json"
318
-
319
- register_tool name=subagents_prompts \
320
- description="Start parallel no-tools subagents from a prompt array as one run actor" \
321
- template="subagents-prompts.json"
322
-
323
- subagent_prompt prompt="Review docs/async-runs.md for unclear wording." run_id=docs-review
324
- subagent_tools prompt="Inspect package metadata and report risks." tools="read,bash" run_id=package-review
325
- subagents_prompts \
326
- prompts='["Review README.md for unclear release-onboarding wording. Return concise findings.","Review docs/template-recipes.md for unclear recipe-import wording. Return concise findings."]' \
327
- run_id=review-prompts
328
- inspect target=run:review-prompts view=tail
329
- ```
257
+ - A generic workflow DSL;
258
+ - A remote agent interoperability protocol;
259
+ - A heavyweight broker or chat subsystem;
260
+ - A sandbox;
261
+ - A facade that hides logs, artifacts, ownership, or local side effects;
262
+ - A polling-first async runner.
330
263
 
331
- The music player recipe starts a local file, URL, directory, or playlist as a run actor, keeps the agent unblocked, shows the ambient triangle indicator in the launching coordinator, and can be controlled with addressed `message` calls. The standard library ships one Node.js wrapper recipe:
264
+ Its job is narrower: make trusted local capabilities addressable, messageable, inspectable, and reusable by agents.
332
265
 
333
- ```text
334
- register_tool name=music_player \
335
- description="Start async music player playback through the Node.js wrapper" \
336
- template="music-player.json" \
337
- args="source:string,loop:bool=true,volume:int=70,player:enum(auto,mpv,ffplay,cvlc,play)=auto"
338
-
339
- music_player source="~/Music" volume=55 run_id=music
340
- message to=run:music type=player.next body=next
341
- message to=run:music type=player.pause body=pause
342
- message to=run:music type=player.play body=play
343
- message to=run:music type=player.stop body=stop
344
- ```
266
+ ## Documentation
345
267
 
346
- See [`docs/recipe-library.md`](./docs/recipe-library.md) for install notes and recipe requirements.
347
-
348
- ## Runtime Contract
349
-
350
- - Actor-control tool names are normalized to snake_case.
351
- - Reserved built-in names are blocked.
352
- - Templates are split into shell-like words first, then placeholders are substituted per command arg.
353
- - Tool args are derived from placeholders when `args` is omitted.
354
- - Typed arg declarations are progressive: `file:path`, `request_timeout:int=60000`, `speed:number=1.5`, `dry_run:bool=true`, `prompts:array`, and `mode:enum(check,fix)=check` can live in `args` or inline placeholders such as `{request_timeout:int=60000}`. They generate narrower tool schemas and runtime validation while existing untyped `args` and placeholders keep working.
355
- - `{arg=default}` inline defaults resolve after runtime values and stored `defaults`; `{arg??fallback}` handles empty/null fallback values; `{flag?--flag:}` ternaries map small truthy/falsy values to strings such as optional CLI flags.
356
- - Runtime actor-tool argument errors include a compact usage hint when typed normalization or template value resolution fails, including example call shape plus required and optional fields.
357
- - `template: [...]` sequences execute left to right; each successful step passes stdout to the next step on stdin.
358
- - Object nodes may set `parallel: true`; children receive the same stdin and joined stdout flows to the next sequence step.
359
- - Parallel nodes use soft-quorum semantics: failed branches are reported as degraded coverage unless failure propagation escalates to the root.
360
- - For long-running work or agentic fanout, prefer `async: true` recipes or `spawn` so lifecycle and ambient activity status remain visible.
361
- - Timeout is disabled by default; set a positive `timeout` on bounded commands that should fail closed. Numeric node fields may read placeholders such as `timeout: "{timeout_ms}"`.
362
- - Nodes may set `when` to skip conditional work and `delay` in milliseconds to wait before launch; delay is not inherited.
363
- - Failed steps default to `failure: "continue"`, which records the failure and continues with empty stdin.
364
- - `failure: "branch"` stops the current sequence/subtree without cancelling sibling parallel branches; `failure: "root"` aborts the composition.
365
- - `retry` retries a leaf or whole node on non-zero exit; default attempts is `1`.
366
- - `recover` runs a cleanup command template between failed retry attempts and stops retries if cleanup fails.
367
- - Commands execute directly without shell evaluation, but trusted executables still run with the same permissions as pi.
368
- - Obvious high-risk templates such as shells, interpreter eval modes, and broad filesystem mutation surface lightweight warnings without blocking existing tools.
369
- - `async: true` on a recipe selects detached run-actor lifecycle; omitted or false runs the recipe foreground through registered tools.
370
- - Layer boundaries stay explicit: command templates define synchronous execution graphs; template recipes add saved JSON metadata/import resolution and named `artifacts`; run actors add detached lifecycle, state, IPC, and observability.
371
- - `spawn`, `message`, and `inspect` are high-level actor adapters. `spawn` creates `run:<id>` actors from recipes or inline templates with optional state/artifact metadata, `message` sends one typed envelope to `run:<id>` mailboxes, `branch:<run>/<branch>` mailboxes, `tool:<name>` calls, or coordinator/session attention paths, and `inspect` intentionally reads `run:<id>` status/tail/messages/mailbox metadata, coordinator/session run status, or registered `tool:<name>` contracts while the broader actor/message protocol is refined.
372
- - `spawn`, `message`, and `inspect` are the public async coordination vocabulary. Low-level async actions map to this actor API: start belongs to `spawn`; send/control/stop/kill belongs to `message`; status/tail/messages/list belongs to `inspect`. Use `inspect view=messages` for actor-envelope streams. Use `control.stop`, `control.cancel`, and `control.kill` for run termination; runtime-prefixed control aliases are no longer part of the public surface.
373
- - Actor management returns compact text by default; pass `verbose: true` to `inspect` when full JSON state is needed.
374
- - Detached runs inject `{run_id}` and `{state_dir}` into template values for run-local artifacts or recipe-specific control endpoints.
375
- - Runtime actor messages are persisted in the run state dir; coordinator attention is inferred by the runtime, not exposed as recipe or message-envelope input. Follow-ups preserve bounded body previews and metadata for decision messages.
376
- - Native Windows should use WSL or a recipe-specific transport for run-local message-controlled recipes; Linux uses stricter `/proc` runner ownership checks for stale PID protection.
377
- - Registered tools may set `template` to a recipe JSON path/name; calling them follows that recipe's `async` mode.
378
- - File-backed recipes may declare `imports` and embed imported recipes with `{ "name": "alias" }` nodes, or read `{alias.defaults.key}`, `{alias.defaults.key=fallback}`, and `{alias.values.key?yes:no}` references before command-template execution.
379
- - Interactive sessions show ambient actor activity as stable `▷` triangles aggregated across runs started by the current agent session. Each running run actor contributes at least one triangle; parallel active branches can contribute more. One `▶` wave moves over the active set; terminal `done`/`failed`/unhandled `killed`/`exited` messages are delivered as compact follow-up context only to the launching coordinator agent, while intentional `cancel`, `kill`, and `stop` actions stay silent because the action already reports synchronously. Failed commands and in-flight parallel branch completions can bubble through `command.done`; successful final leaf completions remain diagnostic to avoid sequential pipeline noise.
380
- - Use `{file}` as the canonical local file path arg.
381
- - Stored `script` entries are rejected with migration guidance.
382
-
383
- See [`docs/command-templates.md`](./docs/command-templates.md) for the portable synchronous command-template contract; [`docs/template-recipes.md`](./docs/template-recipes.md) for saved recipe JSON; [`docs/async-runs.md`](./docs/async-runs.md) for detached lifecycle, state files, cancellation, and observability; [`docs/tool-registry.md`](./docs/tool-registry.md) for registry storage; and [`docs/recipe-library.md`](./docs/recipe-library.md) for the packaged standard recipe library.
384
-
385
- ## Notes
386
-
387
- - Only register trusted local commands. Registered tools run with the same system permissions as pi.
388
- - `index.ts` is a small composition root; reusable behavior lives in flat `/lib` domains covered by focused tests.
268
+ Start here:
269
+
270
+ - [Project context](./AGENTS.md)
271
+ - [Changelog](./CHANGELOG.md)
272
+ - [Open backlog](./BACKLOG.md)
273
+ - [Documentation index](./docs/README.md)
274
+ - [Actors skill](./skills/actors/SKILL.md)
275
+ - [Swarm skill](./skills/swarm/SKILL.md)
276
+
277
+ Core docs:
278
+
279
+ - [Command templates](./docs/command-templates.md)
280
+ - [Template recipes](./docs/template-recipes.md)
281
+ - [Async runs](./docs/async-runs.md)
282
+ - [Actor messages](./docs/actor-messages.md)
283
+ - [Tool registry](./docs/tool-registry.md)
284
+ - [Recipe library](./docs/recipe-library.md)
389
285
 
390
286
  ## License
391
287
 
package/banner.jpg CHANGED
Binary file