@llblab/pi-actors 0.42.3 → 0.43.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/AGENTS.md +127 -175
- package/BACKLOG.md +189 -1
- package/CHANGELOG.md +183 -292
- package/README.md +115 -276
- package/dist/fixtures/protocol/control-endpoint.json +6 -0
- package/dist/fixtures/protocol/control-record.json +9 -0
- package/dist/fixtures/protocol/recipe-summary.json +4 -12
- package/dist/fixtures/protocol/trace-event.json +9 -0
- package/dist/index.js +1 -1
- package/dist/lib/async-runs.d.ts +15 -38
- package/dist/lib/async-runs.js +173 -111
- package/dist/lib/automatic-review-runtime.d.ts +1 -1
- package/dist/lib/automatic-review-runtime.js +5 -5
- package/dist/lib/command-templates.d.ts +2 -0
- package/dist/lib/command-templates.js +38 -4
- package/dist/lib/control-projection.d.ts +20 -0
- package/dist/lib/control-projection.js +66 -0
- package/dist/lib/control.d.ts +15 -0
- package/dist/lib/control.js +97 -0
- package/dist/lib/draft-sleep.js +3 -3
- package/dist/lib/execution-sessions.d.ts +17 -0
- package/dist/lib/execution-sessions.js +85 -0
- package/dist/lib/file-state.d.ts +2 -0
- package/dist/lib/file-state.js +114 -46
- package/dist/lib/inspector-actions.d.ts +2 -2
- package/dist/lib/inspector-actions.js +2 -2
- package/dist/lib/inspector-command.js +3 -3
- package/dist/lib/inspector-overlay.d.ts +54 -70
- package/dist/lib/inspector-overlay.js +576 -910
- package/dist/lib/inspector.d.ts +3 -71
- package/dist/lib/inspector.js +19 -665
- package/dist/lib/limits.d.ts +7 -3
- package/dist/lib/limits.js +7 -3
- package/dist/lib/observability.d.ts +16 -16
- package/dist/lib/observability.js +43 -82
- package/dist/lib/prompts.d.ts +1 -1
- package/dist/lib/prompts.js +3 -3
- package/dist/lib/recipe-control.d.ts +7 -0
- package/dist/lib/recipe-control.js +43 -0
- package/dist/lib/recipes-discovery.js +2 -0
- package/dist/lib/recipes-references.d.ts +1 -14
- package/dist/lib/recipes-references.js +6 -21
- package/dist/lib/review-control.d.ts +1 -1
- package/dist/lib/review-control.js +4 -5
- package/dist/lib/review-projection.js +1 -5
- package/dist/lib/run-ui-runtime.js +2 -2
- package/dist/lib/runs-control-delivery.d.ts +28 -0
- package/dist/lib/runs-control-delivery.js +150 -0
- package/dist/lib/runs-controls.d.ts +37 -0
- package/dist/lib/runs-controls.js +146 -0
- package/dist/lib/runs-retention.d.ts +7 -0
- package/dist/lib/runs-retention.js +27 -3
- package/dist/lib/runs-start.js +4 -2
- package/dist/lib/runs-status.js +11 -6
- package/dist/lib/runs-trace.d.ts +24 -0
- package/dist/lib/runs-trace.js +102 -0
- package/dist/lib/runtime-identity.d.ts +7 -0
- package/dist/lib/runtime-identity.js +35 -0
- package/dist/lib/runtime-notifier.d.ts +1 -1
- package/dist/lib/runtime-notifier.js +1 -1
- package/dist/lib/runtime-triage.d.ts +29 -0
- package/dist/lib/runtime-triage.js +76 -0
- package/dist/lib/tool-review-scheduler.js +7 -7
- package/dist/lib/tools-inspect.d.ts +3 -3
- package/dist/lib/tools-inspect.js +241 -707
- package/dist/lib/tools-local.js +2 -10
- package/dist/lib/tools-message.d.ts +6 -7
- package/dist/lib/tools-message.js +95 -396
- package/dist/lib/tools-response.d.ts +1 -5
- package/dist/lib/tools-response.js +5 -48
- package/dist/lib/tools-spawn.js +16 -28
- package/dist/lib/tools.d.ts +1 -1
- package/dist/lib/tools.js +2 -3
- package/dist/lib/trace-projection.d.ts +22 -0
- package/dist/lib/trace-projection.js +185 -0
- package/dist/recipes/draft-review.json +0 -10
- package/dist/recipes/lens-swarm.json +0 -14
- package/dist/recipes/music-player.json +10 -19
- package/dist/recipes/pipeline-architect-coordinator.json +0 -11
- package/dist/recipes/pipeline-artifact-bundle.json +1 -22
- package/dist/recipes/pipeline-artifact-report.json +1 -18
- package/dist/recipes/pipeline-artifact-write.json +1 -18
- package/dist/recipes/pipeline-async-run-ops.json +0 -12
- package/dist/recipes/pipeline-checkpoint-continuation.json +0 -14
- package/dist/recipes/pipeline-development-tasking.json +0 -12
- package/dist/recipes/pipeline-docs-maintenance.json +0 -12
- package/dist/recipes/pipeline-media-library.json +0 -12
- package/dist/recipes/pipeline-quorum-review.json +0 -12
- package/dist/recipes/pipeline-release-readiness.json +0 -12
- package/dist/recipes/pipeline-release-summary.json +0 -12
- package/dist/recipes/pipeline-repo-health.json +0 -12
- package/dist/recipes/pipeline-research-synthesis.json +0 -11
- package/dist/recipes/pipeline-review-readiness.json +0 -12
- package/dist/recipes/resource-locker.json +27 -0
- package/dist/recipes/subagent-artifact.json +0 -9
- package/dist/recipes/subagent-checkpoint.json +0 -10
- package/dist/recipes/subagent-conflict-report.json +0 -11
- package/dist/recipes/subagent-contradiction-map.json +0 -11
- package/dist/recipes/subagent-critic.json +0 -11
- package/dist/recipes/subagent-evidence-map.json +0 -11
- package/dist/recipes/subagent-followup.json +0 -10
- package/dist/recipes/subagent-judge.json +0 -11
- package/dist/recipes/subagent-merge.json +0 -11
- package/dist/recipes/subagent-normalize.json +0 -11
- package/dist/recipes/subagent-plan.json +0 -11
- package/dist/recipes/subagent-preflight.json +0 -11
- package/dist/recipes/subagent-prompt.json +0 -10
- package/dist/recipes/subagent-quorum.json +0 -10
- package/dist/recipes/subagent-review-coordinator.json +0 -14
- package/dist/recipes/subagent-review.json +0 -11
- package/dist/recipes/subagent-task-card.json +0 -11
- package/dist/recipes/subagent-tools.json +0 -10
- package/dist/recipes/subagent-verify.json +0 -11
- package/dist/recipes/subagents-prompts.json +0 -10
- package/dist/recipes/tool-review.json +0 -10
- package/dist/scripts/async-runner.mjs +25 -25
- package/dist/scripts/conformance.mjs +4 -2
- package/dist/scripts/locker.mjs +196 -69
- package/dist/scripts/music-player.mjs +162 -159
- package/dist/scripts/recipe-utils.mjs +6 -96
- package/dist/scripts/release-gates.mjs +91 -0
- package/dist/scripts/validate-recipe.mjs +8 -57
- package/dist/skills/actors/SKILL.md +57 -265
- package/dist/skills/swarm/SKILL.md +10 -34
- package/docs/0.43-baseline.md +39 -0
- package/docs/README.md +4 -6
- package/docs/actor-inspector.md +26 -64
- package/docs/async-runs.md +81 -328
- package/docs/command-templates.md +8 -118
- package/docs/recipe-library.md +55 -182
- package/docs/releasing.md +28 -0
- package/docs/template-recipes.md +76 -289
- package/docs/tool-registry.md +41 -161
- package/fixtures/protocol/control-endpoint.json +6 -0
- package/fixtures/protocol/control-record.json +9 -0
- package/fixtures/protocol/recipe-summary.json +4 -12
- package/fixtures/protocol/trace-event.json +9 -0
- package/index.ts +1 -1
- package/lib/async-runs.ts +218 -204
- package/lib/automatic-review-runtime.ts +7 -7
- package/lib/command-templates.ts +44 -4
- package/lib/control-projection.ts +105 -0
- package/lib/control.ts +117 -0
- package/lib/draft-sleep.ts +3 -3
- package/lib/execution-sessions.ts +111 -0
- package/lib/file-state.ts +84 -64
- package/lib/inspector-actions.ts +2 -2
- package/lib/inspector-command.ts +3 -3
- package/lib/inspector-overlay.ts +617 -1126
- package/lib/inspector.ts +46 -979
- package/lib/limits.ts +7 -3
- package/lib/observability.ts +60 -101
- package/lib/prompts.ts +3 -3
- package/lib/recipe-control.ts +52 -0
- package/lib/recipes-discovery.ts +2 -0
- package/lib/recipes-references.ts +9 -45
- package/lib/review-control.ts +4 -5
- package/lib/review-projection.ts +1 -5
- package/lib/run-ui-runtime.ts +2 -2
- package/lib/runs-control-delivery.ts +209 -0
- package/lib/runs-controls.ts +213 -0
- package/lib/runs-retention.ts +38 -3
- package/lib/runs-start.ts +4 -2
- package/lib/runs-status.ts +11 -6
- package/lib/runs-trace.ts +136 -0
- package/lib/runtime-identity.ts +39 -0
- package/lib/runtime-notifier.ts +1 -1
- package/lib/runtime-triage.ts +120 -0
- package/lib/tool-review-scheduler.ts +7 -7
- package/lib/tools-inspect.ts +283 -900
- package/lib/tools-local.ts +2 -12
- package/lib/tools-message.ts +112 -520
- package/lib/tools-response.ts +5 -64
- package/lib/tools-spawn.ts +16 -32
- package/lib/tools.ts +5 -6
- package/lib/trace-projection.ts +244 -0
- package/package.json +2 -1
- package/recipes/draft-review.json +0 -10
- package/recipes/lens-swarm.json +0 -14
- package/recipes/music-player.json +10 -19
- package/recipes/pipeline-architect-coordinator.json +0 -11
- package/recipes/pipeline-artifact-bundle.json +1 -22
- package/recipes/pipeline-artifact-report.json +1 -18
- package/recipes/pipeline-artifact-write.json +1 -18
- package/recipes/pipeline-async-run-ops.json +0 -12
- package/recipes/pipeline-checkpoint-continuation.json +0 -14
- package/recipes/pipeline-development-tasking.json +0 -12
- package/recipes/pipeline-docs-maintenance.json +0 -12
- package/recipes/pipeline-media-library.json +0 -12
- package/recipes/pipeline-quorum-review.json +0 -12
- package/recipes/pipeline-release-readiness.json +0 -12
- package/recipes/pipeline-release-summary.json +0 -12
- package/recipes/pipeline-repo-health.json +0 -12
- package/recipes/pipeline-research-synthesis.json +0 -11
- package/recipes/pipeline-review-readiness.json +0 -12
- package/recipes/resource-locker.json +27 -0
- package/recipes/subagent-artifact.json +0 -9
- package/recipes/subagent-checkpoint.json +0 -10
- package/recipes/subagent-conflict-report.json +0 -11
- package/recipes/subagent-contradiction-map.json +0 -11
- package/recipes/subagent-critic.json +0 -11
- package/recipes/subagent-evidence-map.json +0 -11
- package/recipes/subagent-followup.json +0 -10
- package/recipes/subagent-judge.json +0 -11
- package/recipes/subagent-merge.json +0 -11
- package/recipes/subagent-normalize.json +0 -11
- package/recipes/subagent-plan.json +0 -11
- package/recipes/subagent-preflight.json +0 -11
- package/recipes/subagent-prompt.json +0 -10
- package/recipes/subagent-quorum.json +0 -10
- package/recipes/subagent-review-coordinator.json +0 -14
- package/recipes/subagent-review.json +0 -11
- package/recipes/subagent-task-card.json +0 -11
- package/recipes/subagent-tools.json +0 -10
- package/recipes/subagent-verify.json +0 -11
- package/recipes/subagents-prompts.json +0 -10
- package/recipes/tool-review.json +0 -10
- package/scripts/async-runner.mjs +25 -25
- package/scripts/conformance.mjs +4 -2
- package/scripts/locker.mjs +196 -69
- package/scripts/music-player.mjs +162 -159
- package/scripts/recipe-utils.mjs +6 -96
- package/scripts/release-gates.mjs +91 -0
- package/scripts/validate-recipe.mjs +8 -57
- package/skills/actors/SKILL.md +57 -265
- package/skills/swarm/SKILL.md +10 -34
- package/dist/fixtures/protocol/actor-message-branch.json +0 -13
- package/dist/fixtures/protocol/mailbox-contract.json +0 -15
- package/dist/fixtures/protocol/room-message.json +0 -11
- package/dist/fixtures/protocol/room-roster.json +0 -11
- package/dist/fixtures/protocol/run-inbox-message.json +0 -9
- package/dist/fixtures/protocol/run-outbox-event.json +0 -9
- package/dist/lib/mailbox-loop.d.ts +0 -41
- package/dist/lib/mailbox-loop.js +0 -60
- package/dist/lib/messages.d.ts +0 -25
- package/dist/lib/messages.js +0 -122
- package/dist/lib/rooms.d.ts +0 -104
- package/dist/lib/rooms.js +0 -647
- package/dist/lib/runs-mailbox.d.ts +0 -25
- package/dist/lib/runs-mailbox.js +0 -146
- package/dist/lib/runs-messages.d.ts +0 -15
- package/dist/lib/runs-messages.js +0 -179
- package/dist/lib/runs-outbox.d.ts +0 -41
- package/dist/lib/runs-outbox.js +0 -87
- package/dist/lib/tools-mailbox.d.ts +0 -8
- package/dist/lib/tools-mailbox.js +0 -48
- package/dist/recipes/actor-worker.json +0 -39
- package/dist/recipes/coordinator-locker.json +0 -45
- package/dist/recipes/locker.json +0 -45
- package/dist/recipes/pipeline-room-swarm.json +0 -50
- package/dist/recipes/subagent-message.json +0 -32
- package/dist/recipes/utility-actor-message.json +0 -23
- package/dist/scripts/actor-worker.mjs +0 -214
- package/dist/scripts/coordinator.mjs +0 -799
- package/docs/actor-messages.md +0 -225
- package/docs/actors-deep-reference.md +0 -66
- package/docs/component-recipes.md +0 -148
- package/docs/task-first-recipes.md +0 -263
- package/fixtures/protocol/actor-message-branch.json +0 -13
- package/fixtures/protocol/mailbox-contract.json +0 -15
- package/fixtures/protocol/room-message.json +0 -11
- package/fixtures/protocol/room-roster.json +0 -11
- package/fixtures/protocol/run-inbox-message.json +0 -9
- package/fixtures/protocol/run-outbox-event.json +0 -9
- package/lib/mailbox-loop.ts +0 -144
- package/lib/messages.ts +0 -151
- package/lib/rooms.ts +0 -939
- package/lib/runs-mailbox.ts +0 -208
- package/lib/runs-messages.ts +0 -252
- package/lib/runs-outbox.ts +0 -144
- package/lib/tools-mailbox.ts +0 -56
- package/recipes/actor-worker.json +0 -39
- package/recipes/coordinator-locker.json +0 -45
- package/recipes/locker.json +0 -45
- package/recipes/pipeline-room-swarm.json +0 -50
- package/recipes/subagent-message.json +0 -32
- package/recipes/utility-actor-message.json +0 -23
- package/scripts/actor-worker.mjs +0 -214
- package/scripts/coordinator.mjs +0 -799
package/docs/template-recipes.md
CHANGED
|
@@ -1,357 +1,144 @@
|
|
|
1
|
-
# Template
|
|
1
|
+
# Template Recipes
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A Recipe stores a reusable command-template definition as JSON or Markdown.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
**Scope:** reusable JSON/Markdown shape, recipe naming, file-backed recipes, co-located recipes, recipe-layer imports/references, call-time values, foreground execution, and the `async: true` handoff to the [Async Run Standard](./async-runs.md).
|
|
8
|
-
|
|
9
|
-
---
|
|
10
|
-
|
|
11
|
-
## Reading Model
|
|
12
|
-
|
|
13
|
-
```text
|
|
14
|
-
command template = execution graph
|
|
15
|
-
recipe = saved JSON definition
|
|
16
|
-
run = one execution instance
|
|
17
|
-
async: true = run through detached lifecycle
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
A recipe wraps one command-template tree. The wrapped `template` keeps the normal command-template semantics: argv splitting, placeholders, defaults, typed args, sequence, `parallel: true`, `when`, delay, retry, failure propagation, recover cleanup, and output selection.
|
|
21
|
-
|
|
22
|
-
Layer boundary: `imports`, `{ "name": "alias" }` imported-recipe nodes, `{alias.defaults.key}` references, fallback expressions, and recipe-local ternaries are recipe-loading features. They resolve before the command-template graph runs and do not extend the portable Command Template Standard. Typed imports are recipe definitions: they expose the imported recipe's command-template-shaped metadata (`template`, `args`, `defaults`, flags, and `values`), while async-run launch fields such as `async` and `retire_when` remain lifecycle configuration for starting a run, not part of the imported execution graph. Run state directories are runtime-owned and are not recipe or `register_tool` configuration; `{state_dir}` remains an injected run-local value for commands and artifact paths.
|
|
23
|
-
|
|
24
|
-
Packaged recipes are the pi-actors recipe standard library: declarative actor config components that can be imported, launched, inspected, overridden, or composed by user recipes. Treat them as stable building blocks rather than user-local policy.
|
|
25
|
-
|
|
26
|
-
## Layer Ownership
|
|
27
|
-
|
|
28
|
-
Template-recipe standard owns:
|
|
29
|
-
|
|
30
|
-
- Saved JSON definitions around one command-template graph, plus Markdown-authored recipes that compile to that shape.
|
|
31
|
-
- File-backed and co-located recipe shapes.
|
|
32
|
-
- Recipe identity through file-backed filename or co-located tool id.
|
|
33
|
-
- Recipe defaults, values, imports, import references, and import-node expansion.
|
|
34
|
-
- Ordered named artifact declarations through `artifacts`.
|
|
35
|
-
- Foreground-vs-detached selection through `async: true` when invoked by a recipe-aware host.
|
|
36
|
-
|
|
37
|
-
Template-recipe standard does not own:
|
|
38
|
-
|
|
39
|
-
- How command-template nodes execute internally.
|
|
40
|
-
- Async state files, logs, run-local transports, status, cancellation, or observability.
|
|
41
|
-
- Tool registry naming, button UX, package installation, or operator-specific policy.
|
|
42
|
-
- Domain workflows such as swarm quorum, release policy, backlog parsing, or merge policy.
|
|
43
|
-
|
|
44
|
-
A recipe can be synchronous or asynchronous:
|
|
45
|
-
|
|
46
|
-
- Omitted or false `async`: a registered tool executes the recipe in the foreground and returns normal tool output.
|
|
47
|
-
- `async: true`: a registered tool starts a detached async run and returns run metadata immediately.
|
|
48
|
-
|
|
49
|
-
## Minimal Shape
|
|
50
|
-
|
|
51
|
-
Synchronous recipe:
|
|
52
|
-
|
|
53
|
-
```json
|
|
54
|
-
{
|
|
55
|
-
"template": "npm run check:docs"
|
|
56
|
-
}
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
Async recipe:
|
|
5
|
+
## JSON
|
|
60
6
|
|
|
61
7
|
```json
|
|
62
8
|
{
|
|
63
9
|
"async": true,
|
|
64
|
-
"
|
|
10
|
+
"description": "Create a repository health artifact",
|
|
11
|
+
"args": ["repo:path", "artifact_path:path", "model:string"],
|
|
12
|
+
"defaults": { "artifact_path": "{state_dir}/health.md" },
|
|
13
|
+
"imports": { "review": "subagent-review.json" },
|
|
14
|
+
"artifacts": { "report": "{artifact_path}" },
|
|
15
|
+
"template": {
|
|
16
|
+
"name": "review",
|
|
17
|
+
"values": { "input": "Inspect {repo}", "model": "{model}" }
|
|
18
|
+
}
|
|
65
19
|
}
|
|
66
20
|
```
|
|
67
21
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
## Markdown Authoring
|
|
22
|
+
## Markdown
|
|
71
23
|
|
|
72
|
-
Markdown
|
|
24
|
+
Markdown Recipes use YAML frontmatter and one executable fence:
|
|
73
25
|
|
|
74
26
|
````markdown
|
|
75
27
|
---
|
|
76
|
-
description:
|
|
28
|
+
description: Summarize one file
|
|
77
29
|
args:
|
|
78
|
-
-
|
|
79
|
-
defaults:
|
|
80
|
-
scope: docs
|
|
81
|
-
mailbox:
|
|
82
|
-
accepts:
|
|
83
|
-
- control.kill
|
|
30
|
+
- file:path
|
|
84
31
|
---
|
|
85
32
|
|
|
86
|
-
Human notes
|
|
33
|
+
Human notes remain advisory.
|
|
87
34
|
|
|
88
35
|
```template
|
|
89
|
-
|
|
36
|
+
summarize {file}
|
|
90
37
|
```
|
|
91
38
|
````
|
|
92
39
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
JSON remains the source-of-truth format for precise machine editing. If `<id>.json` and `<id>.md` exist in the same discovery priority layer, `<id>.json` wins and the Markdown recipe is reported as shadowed.
|
|
96
|
-
|
|
97
|
-
## Discovery Priority
|
|
98
|
-
|
|
99
|
-
Recipe priority only matters when two discovered recipes have the same filename id. The conceptual ladder from lowest to highest priority is:
|
|
100
|
-
|
|
101
|
-
1. No recipe for that id.
|
|
102
|
-
2. Packaged pi-actors recipe components, acting as the standard library.
|
|
103
|
-
3. Explicitly referenced ad hoc user recipe files located outside `~/.pi/agent/recipes`.
|
|
104
|
-
4. User recipe files under `~/.pi/agent/recipes/*.json` or `*.md`.
|
|
105
|
-
|
|
106
|
-
The high-priority user recipe directory is also the default tool set: recipes placed there are agent tools by location. This preserves the old advantage of a tool-only registry because listing `~/.pi/agent/recipes` shows the operator-managed tool surface. Packaged and ad hoc recipes are recipe components by default; they become tools only when copied or registered into the agent recipe root.
|
|
40
|
+
Fences marked `template`, `command-template`, `json`, or `recipe` can define execution. Frontmatter supports Recipe metadata and command-template flags.
|
|
107
41
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
## Usage And Lineage Metadata
|
|
111
|
-
|
|
112
|
-
User-owned recipe launches update extension-maintained lineage ledgers under `.usage/recipes/<recipe-name>.json` plus a path index. Authored recipes remain untouched. The ledger keeps lifetime and revision-local launch counts, executable fingerprints, former names and paths, bounded revision ancestry, transition events, and review epochs.
|
|
113
|
-
|
|
114
|
-
Lifetime usage survives rename, promotion, demotion, and executable revision. Revision-local counters restart when executable content changes, making the new fingerprint eligible for portfolio review without erasing prior evidence. Discovery merges current lineage evidence into inspection; packaged standard-library recipes receive no mutable usage ledger. The unreleased format stays intentionally unversioned until a public compatibility boundary exists.
|
|
115
|
-
|
|
116
|
-
There is intentionally no failure counter: a failed launch can reflect caller misuse, missing values, or environment state rather than recipe quality. Usage remains evidence, not an automatic usefulness verdict. Automatic review combines it with contract quality, portability, duplication, safety, and likely future value. `register_tool draft=...` is the preferred fenced single-draft override; a deliberate move/copy from `drafts/` into the recipe root also remains valid, though it may defer an already captured automatic batch.
|
|
117
|
-
|
|
118
|
-
For object form, keep `template` last. Recipe metadata comes first; executable content stays last.
|
|
119
|
-
|
|
120
|
-
## Named Artifacts
|
|
121
|
-
|
|
122
|
-
Use recipe-level `artifacts` to declare stable artifact names and paths for the whole recipe, ordered from most important to least important:
|
|
123
|
-
|
|
124
|
-
```json
|
|
125
|
-
{
|
|
126
|
-
"args": ["report_path:path"],
|
|
127
|
-
"defaults": { "report_path": "artifacts/report.md" },
|
|
128
|
-
"artifacts": {
|
|
129
|
-
"report": "{report_path}",
|
|
130
|
-
"summary": "artifacts/summary.json"
|
|
131
|
-
},
|
|
132
|
-
"template": "generate-report --out {report_path}"
|
|
133
|
-
}
|
|
134
|
-
```
|
|
135
|
-
|
|
136
|
-
`output` and `artifacts` are intentionally different. `output` is the command-template primary result selector and defaults to stdout; it participates in sequence/stdin flow. `artifacts` is recipe metadata: an ordered named artifact manifest for humans, async completion messages, and downstream tooling. `stdout` remains the default command result channel and is not renamed by `artifacts`.
|
|
137
|
-
|
|
138
|
-
## Mailbox
|
|
139
|
-
|
|
140
|
-
Use recipe-level `mailbox` to document the semantic messages a recipe actor accepts and emits:
|
|
141
|
-
|
|
142
|
-
```json
|
|
143
|
-
{
|
|
144
|
-
"mailbox": {
|
|
145
|
-
"accepts": [
|
|
146
|
-
"control.continue",
|
|
147
|
-
"control.revise",
|
|
148
|
-
"control.approve",
|
|
149
|
-
"control.kill"
|
|
150
|
-
],
|
|
151
|
-
"emits": ["checkpoint.needs_scope", "branch.done", "run.done"]
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
```
|
|
155
|
-
|
|
156
|
-
`mailbox` is contract metadata, not transport configuration. It should name semantic message types, not transport commands, file paths, or CLI fragments. Entries may be strings or typed objects such as `{ "type": "task.assign", "requires_response": true, "summary": "Assign work" }`; inspection normalizes both forms. Acceptance contracts are advisory by default: messages outside `mailbox.accepts` produce warnings rather than hard routing failures.
|
|
157
|
-
|
|
158
|
-
## Actor Recipe Context
|
|
159
|
-
|
|
160
|
-
File-backed async recipes automatically build a bounded recipe context bundle for child LLM actor launches. The bundle is appended to child `pi -p` prompts as JSONL: each line is one recipe/context record containing filename-derived `name`, source file, role/depth, import path/alias, and the raw authored recipe JSON. The record whose command-template node launched the current child is marked with `"you_are_here": true` and path metadata.
|
|
161
|
-
|
|
162
|
-
This context is provenance, not the task instruction. The authored prompt remains authoritative; the bundle explains the recipe/composition tree that produced the launch. A child actor can use it to give advisory feedback on whether its recipe, imports, mailbox metadata, and role boundaries fit the task, without needing a separate hand-written workflow explanation. Recipes that require a minimal child prompt may opt out:
|
|
163
|
-
|
|
164
|
-
```json
|
|
165
|
-
{
|
|
166
|
-
"async": true,
|
|
167
|
-
"actor_context": false,
|
|
168
|
-
"template": "pi -p --model {model} {prompt}"
|
|
169
|
-
}
|
|
170
|
-
```
|
|
42
|
+
## Fields
|
|
171
43
|
|
|
172
|
-
|
|
44
|
+
Common Recipe fields:
|
|
173
45
|
|
|
174
|
-
|
|
46
|
+
- `name`, `description`, `disabled`;
|
|
47
|
+
- `args`, typed arg declarations, and `defaults`;
|
|
48
|
+
- `imports` with optional binding defaults/values;
|
|
49
|
+
- `template`;
|
|
50
|
+
- `async`;
|
|
51
|
+
- `artifacts`;
|
|
52
|
+
- `control` for actual controlled services;
|
|
53
|
+
- command-template flags such as `parallel`, `concurrency`, `min_successful`, `when`, `timeout`, `delay`, `retry`, `failure`, `recover`, `repeat`, `accept_output`, and `output`;
|
|
54
|
+
- `retire_when: "children_terminal"` for opt-in supervisor retirement.
|
|
175
55
|
|
|
176
|
-
|
|
56
|
+
## Imports
|
|
177
57
|
|
|
178
58
|
```json
|
|
179
59
|
{
|
|
180
|
-
"
|
|
181
|
-
"
|
|
182
|
-
"
|
|
60
|
+
"imports": {
|
|
61
|
+
"review": "subagent-review.json",
|
|
62
|
+
"verify": {
|
|
63
|
+
"from": "subagent-verify.json",
|
|
64
|
+
"defaults": { "thinking": "medium" }
|
|
65
|
+
}
|
|
183
66
|
},
|
|
184
|
-
"template":
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
## Command-Template Flags At Recipe Top Level
|
|
189
|
-
|
|
190
|
-
Top-level command-template flags may sit beside recipe metadata such as `async`:
|
|
191
|
-
|
|
192
|
-
```json
|
|
193
|
-
{
|
|
194
|
-
"async": true,
|
|
195
|
-
"parallel": true,
|
|
196
|
-
"timeout": 300000,
|
|
197
|
-
"failure": "branch",
|
|
198
|
-
"template": ["review-a docs/spec.md", "review-b docs/spec.md"]
|
|
67
|
+
"template": [
|
|
68
|
+
{ "name": "review", "values": { "input": "{input}" } },
|
|
69
|
+
{ "name": "verify", "values": { "input": "Use prior output" } }
|
|
70
|
+
]
|
|
199
71
|
}
|
|
200
72
|
```
|
|
201
73
|
|
|
202
|
-
|
|
74
|
+
Imports are local definitions. Named nodes call imported templates inside the same execution graph and Run. Resolution enforces Recipe-root priority, file-size/depth bounds, and cycle rejection.
|
|
203
75
|
|
|
204
|
-
|
|
76
|
+
Direct delegation can use another Recipe as the entire template. The delegated Recipe remains the source of truth while the wrapper may narrow args/defaults or override selected lifecycle metadata.
|
|
205
77
|
|
|
206
|
-
##
|
|
78
|
+
## Control
|
|
207
79
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
```text
|
|
211
|
-
tool → template reference → recipe → run → template
|
|
212
|
-
```
|
|
213
|
-
|
|
214
|
-
A recipe must define `template` directly. Tool exposure comes from where the recipe is stored, so the same recipe remains transportable across user, ad hoc, and packaged roots.
|
|
215
|
-
|
|
216
|
-
A recipe may live in a file or be co-located inside a registered tool entry. Both are storage variants of the same graph.
|
|
217
|
-
|
|
218
|
-
## File-Backed Recipes
|
|
219
|
-
|
|
220
|
-
Reusable local recipes live in:
|
|
221
|
-
|
|
222
|
-
```text
|
|
223
|
-
~/.pi/agent/recipes/*.json
|
|
224
|
-
~/.pi/agent/recipes/*.md
|
|
225
|
-
```
|
|
226
|
-
|
|
227
|
-
Bare recipe names resolve under that directory, so `file: "review-docs"` loads:
|
|
228
|
-
|
|
229
|
-
```text
|
|
230
|
-
~/.pi/agent/recipes/review-docs.json
|
|
231
|
-
# or, when no same-id JSON file exists:
|
|
232
|
-
~/.pi/agent/recipes/review-docs.md
|
|
233
|
-
```
|
|
234
|
-
|
|
235
|
-
Call-time params override file params. `values` are merged with file values; call-time values win. If a run id is omitted for an explicit async start, the file basename becomes the default run id.
|
|
236
|
-
|
|
237
|
-
## Registered Recipe Tools
|
|
238
|
-
|
|
239
|
-
A registered tool is a recipe file exposed as an agent tool. User recipes under `~/.pi/agent/recipes/*.json` or `*.md` are tools by location; packaged/ad hoc recipes are components unless copied or registered into that user recipe root:
|
|
80
|
+
Only a process that consumes actor-local input declares actions:
|
|
240
81
|
|
|
241
82
|
```json
|
|
242
83
|
{
|
|
243
|
-
"description": "Start an async docs review actor",
|
|
244
84
|
"async": true,
|
|
245
|
-
"
|
|
246
|
-
"template": "
|
|
85
|
+
"control": ["pause", "resume", "stop"],
|
|
86
|
+
"template": "{repo}/scripts/service.mjs --state-dir {state_dir}"
|
|
247
87
|
}
|
|
248
88
|
```
|
|
249
89
|
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
## Values And Public Args
|
|
253
|
-
|
|
254
|
-
Recipe placeholders come from runtime values, recipe `defaults`, inline placeholder defaults, and registered-tool defaults. Pi tool launches also inject `{current_model}` and `{current_thinking}` when the active session exposes a selected model and thinking level; recipes that require those placeholders fail before fanout when the current value is unavailable unless the caller supplies an explicit override such as `model` or `thinking`. Async runs persist `model_policy` provenance in run status, progress, and terminal results so operators can tell whether model/thinking values were inherited, explicit, mixed, or unresolved.
|
|
255
|
-
|
|
256
|
-
Recipe tools derive public arguments from the referenced or co-located command template when the recipe is available locally. Explicit `args` is still available when the public tool surface should be narrower than the recipe internals.
|
|
90
|
+
Actions must be lowercase ASCII, unique, non-reserved, and at most 64 characters. Serialized Control input is at most 380 bytes so every admitted wire record remains within 512 bytes on FIFO and named pipe. One-shot Recipes omit Control. Larger data belongs in a declared artifact/path; outputs belong in Trace, artifacts, execution evidence, or the command result.
|
|
257
91
|
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
## Recipe Imports
|
|
261
|
-
|
|
262
|
-
File-backed recipes may import other file-backed recipes at the recipe layer. Imports are resolved before the command-template graph is executed, so command-template core stays registry-free and synchronous. Recipe loading is intentionally bounded: a single recipe file larger than 1 MiB is rejected before JSON parsing, and import chains deeper than 32 are rejected before further resolution. Split very large prompts/data into explicit files or artifacts and keep recipe graphs shallow enough for operator review.
|
|
92
|
+
## Artifacts
|
|
263
93
|
|
|
264
94
|
```json
|
|
265
95
|
{
|
|
266
|
-
"
|
|
267
|
-
|
|
268
|
-
"
|
|
269
|
-
|
|
270
|
-
"from": "run-tests.json",
|
|
271
|
-
"values": { "suite": "unit" }
|
|
272
|
-
}
|
|
273
|
-
},
|
|
274
|
-
"template": [{ "name": "prepare" }, { "name": "test" }]
|
|
96
|
+
"artifacts": {
|
|
97
|
+
"report": "{state_dir}/report.md",
|
|
98
|
+
"manifest": "{state_dir}/manifest.json"
|
|
99
|
+
}
|
|
275
100
|
}
|
|
276
101
|
```
|
|
277
102
|
|
|
278
|
-
|
|
103
|
+
Artifact paths resolve under containment policy and appear in Run inspection. Recipes should write declared artifacts deterministically and fail when the requested write policy cannot be honored.
|
|
279
104
|
|
|
280
|
-
|
|
281
|
-
- `defaults`: extra default values exposed through the import.
|
|
282
|
-
- `values`: explicit values for embedding that imported recipe.
|
|
105
|
+
## Context and Provenance
|
|
283
106
|
|
|
284
|
-
|
|
107
|
+
File-backed Runs capture Recipe context records for the entry and imports. The captured bundle explains composition identity and remains generation-local evidence. It does not override the authored task prompt.
|
|
285
108
|
|
|
286
|
-
|
|
109
|
+
Recipes that need a minimal child prompt may opt out of injected Recipe context through the documented `actor_context` launch option.
|
|
287
110
|
|
|
288
|
-
##
|
|
111
|
+
## Current Policy
|
|
289
112
|
|
|
290
|
-
|
|
113
|
+
Defaults can inherit current Pi policy:
|
|
291
114
|
|
|
292
115
|
```json
|
|
293
116
|
{
|
|
294
|
-
"
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
117
|
+
"defaults": {
|
|
118
|
+
"model": "{current_model}",
|
|
119
|
+
"thinking": "{current_thinking}"
|
|
120
|
+
}
|
|
298
121
|
}
|
|
299
122
|
```
|
|
300
123
|
|
|
301
|
-
|
|
124
|
+
Resolution fails before launch when required current policy is unavailable. The Run persists whether values were inherited or explicit.
|
|
302
125
|
|
|
303
|
-
|
|
126
|
+
## Resolution and Shadowing
|
|
304
127
|
|
|
305
|
-
|
|
128
|
+
User Recipes under `~/.pi/agent/recipes` take priority over packaged Recipes. An invalid active file blocks fallback and reports both paths. Disabled Recipes cannot launch. Registry watchers converge after atomic changes without executing partial definitions.
|
|
306
129
|
|
|
307
|
-
|
|
308
|
-
{
|
|
309
|
-
"async": true,
|
|
310
|
-
"imports": {
|
|
311
|
-
"review": "review-one.json"
|
|
312
|
-
},
|
|
313
|
-
"parallel": true,
|
|
314
|
-
"failure": "branch",
|
|
315
|
-
"template": [
|
|
316
|
-
{ "name": "review", "values": { "scope": "README.md" } },
|
|
317
|
-
{ "name": "review", "values": { "scope": "docs/template-recipes.md" } }
|
|
318
|
-
]
|
|
319
|
-
}
|
|
320
|
-
```
|
|
321
|
-
|
|
322
|
-
Recipes can also read imported metadata and value containers before command-template placeholder expansion. Each import alias acts like a recipe-local variable:
|
|
130
|
+
## Validation
|
|
323
131
|
|
|
324
|
-
```
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
"base": {
|
|
328
|
-
"from": "base.json",
|
|
329
|
-
"values": { "target": "docs" }
|
|
330
|
-
}
|
|
331
|
-
},
|
|
332
|
-
"defaults": {
|
|
333
|
-
"profile": "{base.defaults.profile=safe}",
|
|
334
|
-
"target": "{base.values.target}",
|
|
335
|
-
"label": "{base.name}:{base.values.target}",
|
|
336
|
-
"enabled_label": "{base.defaults.enabled?enabled:disabled}"
|
|
337
|
-
},
|
|
338
|
-
"template": "run {base.defaults.profile=safe} {base.values.target} {label}"
|
|
339
|
-
}
|
|
132
|
+
```bash
|
|
133
|
+
node scripts/validate-recipe.mjs recipes/example.json --qa
|
|
134
|
+
node scripts/validate-recipe.mjs recipes --all --qa --summary
|
|
340
135
|
```
|
|
341
136
|
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
- `{alias.name}`
|
|
345
|
-
- `{alias.file}`
|
|
346
|
-
- `{alias.defaults.key}`
|
|
347
|
-
- `{alias.values.key}`
|
|
348
|
-
- `{alias.defaults.key=fallback}` for a missing/null import value fallback.
|
|
349
|
-
- `{alias.values.key?truthy:falsy}` for a small recipe-layer ternary.
|
|
350
|
-
|
|
351
|
-
Nested object keys are dot-separated. Import references are resolved before normal command-template placeholders, so ordinary values such as `{label}` still flow through command-template defaults and call-time values. Ternaries use simple falsy checks for missing, null, false, zero, and empty string. Missing imports, missing values without fallback, and import cycles fail during recipe loading.
|
|
352
|
-
|
|
353
|
-
## Recipe Shape
|
|
137
|
+
Validation checks JSON/Markdown compilation, imports, Control, artifacts, helper paths, and platform notes. Files exceed 1 MiB or import depth 32 fail closed.
|
|
354
138
|
|
|
355
|
-
|
|
139
|
+
## Related
|
|
356
140
|
|
|
357
|
-
|
|
141
|
+
- [Command templates](./command-templates.md)
|
|
142
|
+
- [Runs](./async-runs.md)
|
|
143
|
+
- [Recipe library](./recipe-library.md)
|
|
144
|
+
- [Tool registry](./tool-registry.md)
|