@llblab/pi-actors 0.19.2 → 0.19.3
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 +1 -1
- package/CHANGELOG.md +8 -0
- package/README.md +1 -1
- package/docs/async-runs.md +2 -2
- package/lib/async-runs.ts +5 -0
- package/lib/observability.ts +42 -2
- package/lib/prompts.ts +1 -1
- package/lib/tools.ts +2 -0
- package/package.json +1 -1
- package/skills/actors/SKILL.md +2 -1
- package/skills/swarm/SKILL.md +1 -1
package/AGENTS.md
CHANGED
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
|
|
40
40
|
- `Knowledge surface separation`: pi-actors has distinct knowledge surfaces with different context-entry behavior: injected prompt is always present and should stay a tiny bootstrap/reminder; packaged `actors` skill is auto-matched by name/description and should signal that its body is the highest-density practical guide for operating the extension plus the shortest navigator to bundled recipes; packaged `swarm` skill is auto-matched for multi-agent methodology, strategies, standards, and portable examples; README is the human entrypoint explaining concept, rhythm, benefits, and scenarios but is not automatically in context; `/docs` are detailed transportable standards read on demand; `AGENTS.md` is project context and architectural constraints for agents changing the repo | Trigger: Editing prompt copy, README, docs, skills, or project context | Action: Keep each surface on its own wave, avoid duplicating prompt and skill headers, keep the actors skill recipe navigator compact and concrete, avoid duplicating scenario catalogs or changelog narratives in the actors skill, avoid turning the prompt into docs, keep multi-agent methodology in swarm-oriented guidance rather than the actors skill, keep packaged extension skill metadata versions synchronized with `package.json` version, and avoid extra colons in skill frontmatter scalar lines because skill formatters treat them poorly
|
|
41
41
|
- `Tool registry is executable muscle memory`: `~/.pi/agent/recipes/*.json` is the persistent user tool surface by location: every recipe in that agent root is automatically registered as an agent tool across sessions, and `register_tool` creates/updates/deletes recipe files there under the hood | Trigger: Any runtime registration, recipe discovery, migration, docs, skill, prompt, or recipe authoring work | Action: Treat the directory like `MEMORY.md` for executable habits; preserve filename identity, atomic writes, explicit operator-gated migration paths, and never author a recipe-owned `tool` property in repository recipes, docs, or fixtures; packaged/ad hoc recipes outside the agent root are components, not tools
|
|
42
|
-
- `Current runtime contract`: Register trusted command templates with tool names from registry keys, placeholder-derived args, progressive typed arg declarations, inline/default/`??`/ternary config fallback, placeholder-derived numeric node controls, split-first command-arg construction, sequential or `parallel: true` composition, direct no-shell execution, optional per-node `when`, optional per-node positive `timeout` disabled by default, lightweight warnings for obvious trusted-executable risk shapes, per-node `delay`, bounded leaf/node `retry`, `failure: "continue|branch|root"` propagation, `recover` cleanup between retry attempts, template recipes with explicit `async: true` detached mode, actor-oriented `spawn`/`message`/`inspect` tools with run-local JSONL outbox messages, Unix FIFO send, graceful cancel, and force kill, generic detached run primitives with process-group cancellation, injected async `{run_id}` and `{state_dir}` values, coordinator-scoped event-driven observability with at least one triangle per active async run and extra triangles for active parallel branches, runtime-inferred `command.done` bubbling for packaged multi-agent fanout,
|
|
42
|
+
- `Current runtime contract`: Register trusted command templates with tool names from registry keys, placeholder-derived args, progressive typed arg declarations, inline/default/`??`/ternary config fallback, placeholder-derived numeric node controls, split-first command-arg construction, sequential or `parallel: true` composition, direct no-shell execution, optional per-node `when`, optional per-node positive `timeout` disabled by default, lightweight warnings for obvious trusted-executable risk shapes, per-node `delay`, bounded leaf/node `retry`, `failure: "continue|branch|root"` propagation, `recover` cleanup between retry attempts, template recipes with explicit `async: true` detached mode, actor-oriented `spawn`/`message`/`inspect` tools with run-local JSONL outbox messages, Unix FIFO send, graceful cancel, and force kill, generic detached run primitives with process-group cancellation, injected async `{run_id}` and `{state_dir}` values, coordinator-scoped event-driven observability with at least one triangle per active async run and extra triangles for active parallel branches, runtime-inferred `command.done` bubbling for packaged multi-agent fanout, terminal follow-ups for `done`/`failed`/unhandled `killed`/`exited` states, recipe-persistence suggestions for successful direct inline/ad hoc `spawn` runs that are not already durable user recipes, named recipe `artifacts`, recipe `mailbox` metadata, `template` recipe references, recipe-layer `imports`, file-backed async recipe JSONL context bundles for child `pi -p` actors with raw entry/import recipes and `"you_are_here": true`, co-located recipe entries, `~/.pi/agent/recipes/*.json` template recipe files, run state under `~/.pi/agent/tmp/pi-actors/runs`, and `{file}` as the canonical local file path arg | Trigger: Changing registration or invocation behavior | Action: Keep README, command-template docs, template-recipe docs, async-run docs, actor-message docs, implementation, and migration notes aligned
|
|
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
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.19.3: Spawn Recipe Persistence Suggestions
|
|
4
|
+
|
|
5
|
+
- `[Observability]` Added semi-active recipe persistence suggestions for successful direct `spawn` runs. Inline/ad hoc spawned actors now record `launch_source: "spawn"`, and their successful terminal follow-up asks the agent to offer saving the reusable pattern as a durable recipe/tool under `~/.pi/agent/recipes` without auto-saving.
|
|
6
|
+
- `[Runtime]` Recorded `launch_source` metadata for actor starts so observability can distinguish direct spawns from registered recipe-tool runs and avoid prompting for actors already backed by user-owned recipes.
|
|
7
|
+
- `[Docs/Prompt]` Updated onboarding prompt guidance, README, async-run docs, and project context around ask-first recipe persistence after successful transient actors.
|
|
8
|
+
- `[Tests]` Added regression coverage for successful transient spawn suggestions and suppression when the run already came from a saved user recipe.
|
|
9
|
+
- `[Package]` Bumped package metadata, lockfile metadata, and packaged skill metadata to `0.19.3` for the hotfix release.
|
|
10
|
+
|
|
3
11
|
## 0.19.2: Actor Recipe Context Bundle
|
|
4
12
|
|
|
5
13
|
- `[Actor Context]` Added a recipe context bundle for file-backed async recipes. The runtime now collects the raw authored entry recipe and resolved imports into deterministic JSONL records with filename-derived `name`, import alias/path metadata, role/depth, and raw recipe JSON so spawned LLM actors can understand the workflow composition behind their prompt.
|
package/README.md
CHANGED
|
@@ -239,7 +239,7 @@ Packaged recipes are building blocks. Copy them into `~/.pi/agent/recipes/` or r
|
|
|
239
239
|
|
|
240
240
|
Use a foreground registered tool when the work is short, bounded, and does not need lifecycle.
|
|
241
241
|
|
|
242
|
-
Use an async recipe or `spawn` when the work is long-running, service-like, parallel, agentic, artifact-producing, or needs later control.
|
|
242
|
+
Use an async recipe or `spawn` when the work is long-running, service-like, parallel, agentic, artifact-producing, or needs later control. If a directly spawned inline/ad hoc actor completes successfully, pi-actors sends the launching agent a follow-up note to offer saving that pattern as a durable recipe/tool under `~/.pi/agent/recipes`; the agent should ask first and never auto-save.
|
|
243
243
|
|
|
244
244
|
Use `room:<run>` when multiple actors in the same run need shared context, roster discovery, or group-visible progress.
|
|
245
245
|
|
package/docs/async-runs.md
CHANGED
|
@@ -83,7 +83,7 @@ Use `run_id` on async recipe tools or `as: "run:<id>"` on `spawn` when the calle
|
|
|
83
83
|
|
|
84
84
|
Use ordinary files under the extension temp directory so status tools stay simple and inspectable:
|
|
85
85
|
|
|
86
|
-
- `run.json`: pid, optional source metadata (`tool`, `recipe`, `recipe_file`), command-template config, cwd, coordinator owner id, values, named `artifacts`, mailbox metadata, created time, and state dir.
|
|
86
|
+
- `run.json`: pid, optional source metadata (`launch_source`, `tool`, `recipe`, `recipe_file`), command-template config, cwd, coordinator owner id, values, named `artifacts`, mailbox metadata, created time, and state dir.
|
|
87
87
|
- `communication.json`: compact actor communication snapshot with self/root/parent, default-room, member, and contact hints for room-aware scripts and agents.
|
|
88
88
|
- `progress.json`: phase, active command count, completed count, failures, and updated time.
|
|
89
89
|
- `events.jsonl`: append-only implementation lifecycle log.
|
|
@@ -124,7 +124,7 @@ The core loop is:
|
|
|
124
124
|
{ "recipe": "music-player.json", "as": "run:music" }
|
|
125
125
|
```
|
|
126
126
|
|
|
127
|
-
2. Let terminal completion, `command.done`, and script-authored follow-up messages reach the launching coordinator automatically.
|
|
127
|
+
2. Let terminal completion, `command.done`, and script-authored follow-up messages reach the launching coordinator automatically. When a directly spawned inline/ad hoc actor completes successfully, the coordinator follow-up tells the agent to offer recipe persistence only as a question to the operator; it must not auto-save.
|
|
128
128
|
|
|
129
129
|
3. Respond with explicit run-local messages when needed:
|
|
130
130
|
|
package/lib/async-runs.ts
CHANGED
|
@@ -34,9 +34,12 @@ import * as RecipeUsage from "./recipe-usage.ts";
|
|
|
34
34
|
|
|
35
35
|
const START_LOCK_MAX_AGE_MS = 5 * 60 * 1000;
|
|
36
36
|
|
|
37
|
+
export type AsyncRunLaunchSource = "spawn" | "tool";
|
|
38
|
+
|
|
37
39
|
export interface AsyncRunStartParams {
|
|
38
40
|
async?: boolean;
|
|
39
41
|
file?: string;
|
|
42
|
+
launch_source?: AsyncRunLaunchSource;
|
|
40
43
|
name?: string;
|
|
41
44
|
ownerId?: string;
|
|
42
45
|
run_id?: string;
|
|
@@ -96,6 +99,7 @@ export interface AsyncRunMeta {
|
|
|
96
99
|
argv: string[];
|
|
97
100
|
createdAt: string;
|
|
98
101
|
cwd: string;
|
|
102
|
+
launch_source?: AsyncRunLaunchSource;
|
|
99
103
|
ownerId?: string;
|
|
100
104
|
pid: number;
|
|
101
105
|
recipe?: string;
|
|
@@ -414,6 +418,7 @@ export function startRun(
|
|
|
414
418
|
argv: [process.execPath, ...argv],
|
|
415
419
|
createdAt: new Date().toISOString(),
|
|
416
420
|
cwd,
|
|
421
|
+
...(startParams.launch_source ? { launch_source: startParams.launch_source } : {}),
|
|
417
422
|
...(startParams.ownerId ? { ownerId: startParams.ownerId } : {}),
|
|
418
423
|
pid: 0,
|
|
419
424
|
...(recipe ? { recipe } : {}),
|
package/lib/observability.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import { existsSync, readdirSync, readFileSync } from "node:fs";
|
|
8
|
-
import { basename, dirname, join, relative } from "node:path";
|
|
8
|
+
import { basename, dirname, join, relative, resolve } from "node:path";
|
|
9
9
|
|
|
10
10
|
import * as AsyncRuns from "./async-runs.ts";
|
|
11
11
|
import * as Paths from "./paths.ts";
|
|
@@ -26,9 +26,12 @@ export interface RunObservation {
|
|
|
26
26
|
failures?: number;
|
|
27
27
|
ownerId?: string;
|
|
28
28
|
artifacts?: Record<string, string>;
|
|
29
|
+
launchSource?: AsyncRuns.AsyncRunLaunchSource;
|
|
30
|
+
recipeFile?: string;
|
|
29
31
|
terminalHandled?: boolean;
|
|
30
32
|
retireWhen?: string;
|
|
31
33
|
run: string;
|
|
34
|
+
tool?: string;
|
|
32
35
|
stateDir?: string;
|
|
33
36
|
status: RunObservedStatus;
|
|
34
37
|
updatedAt?: string;
|
|
@@ -57,8 +60,11 @@ export interface RunTransition {
|
|
|
57
60
|
run: string;
|
|
58
61
|
stateDir?: string;
|
|
59
62
|
artifacts?: Record<string, string>;
|
|
63
|
+
launchSource?: AsyncRuns.AsyncRunLaunchSource;
|
|
64
|
+
recipeFile?: string;
|
|
60
65
|
terminalHandled?: boolean;
|
|
61
66
|
to: RunObservedStatus;
|
|
67
|
+
tool?: string;
|
|
62
68
|
}
|
|
63
69
|
|
|
64
70
|
export interface RunOutboxEvent {
|
|
@@ -132,6 +138,12 @@ function observeRun(stateDir: string): RunObservation | undefined {
|
|
|
132
138
|
!Array.isArray(status.artifacts)
|
|
133
139
|
? { artifacts: status.artifacts as Record<string, string> }
|
|
134
140
|
: {}),
|
|
141
|
+
...(status.launch_source === "spawn" || status.launch_source === "tool"
|
|
142
|
+
? { launchSource: status.launch_source }
|
|
143
|
+
: {}),
|
|
144
|
+
...(typeof status.recipe_file === "string"
|
|
145
|
+
? { recipeFile: status.recipe_file }
|
|
146
|
+
: {}),
|
|
135
147
|
...(status.terminal_handled ? { terminalHandled: true } : {}),
|
|
136
148
|
...(typeof status.retire_when === "string"
|
|
137
149
|
? { retireWhen: status.retire_when }
|
|
@@ -139,6 +151,7 @@ function observeRun(stateDir: string): RunObservation | undefined {
|
|
|
139
151
|
run,
|
|
140
152
|
stateDir,
|
|
141
153
|
status: status.status as RunObservedStatus,
|
|
154
|
+
...(typeof status.tool === "string" ? { tool: status.tool } : {}),
|
|
142
155
|
updatedAt: getUpdatedAt(status),
|
|
143
156
|
};
|
|
144
157
|
} catch {
|
|
@@ -365,8 +378,11 @@ export function detectRunTransitions(
|
|
|
365
378
|
run: run.run,
|
|
366
379
|
...(run.stateDir ? { stateDir: run.stateDir } : {}),
|
|
367
380
|
...(run.artifacts ? { artifacts: run.artifacts } : {}),
|
|
381
|
+
...(run.launchSource ? { launchSource: run.launchSource } : {}),
|
|
382
|
+
...(run.recipeFile ? { recipeFile: run.recipeFile } : {}),
|
|
368
383
|
...(run.terminalHandled ? { terminalHandled: true } : {}),
|
|
369
384
|
to: run.status,
|
|
385
|
+
...(run.tool ? { tool: run.tool } : {}),
|
|
370
386
|
});
|
|
371
387
|
}
|
|
372
388
|
previous.set(run.run, run.status);
|
|
@@ -610,11 +626,35 @@ function getRunArtifacts(transition: RunTransition): string[] {
|
|
|
610
626
|
];
|
|
611
627
|
}
|
|
612
628
|
|
|
629
|
+
function isUserRecipeFile(file: string | undefined): boolean {
|
|
630
|
+
if (!file) return false;
|
|
631
|
+
const recipeRoot = resolve(Paths.getRecipeRoot());
|
|
632
|
+
const path = resolve(file);
|
|
633
|
+
return path === recipeRoot || path.startsWith(`${recipeRoot}/`);
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
export function shouldSuggestRecipePersistence(
|
|
637
|
+
transition: RunTransition,
|
|
638
|
+
): boolean {
|
|
639
|
+
return (
|
|
640
|
+
transition.to === "done" &&
|
|
641
|
+
transition.launchSource === "spawn" &&
|
|
642
|
+
!transition.tool &&
|
|
643
|
+
!isUserRecipeFile(transition.recipeFile)
|
|
644
|
+
);
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
function formatRecipePersistenceSuggestion(transition: RunTransition): string {
|
|
648
|
+
if (!shouldSuggestRecipePersistence(transition)) return "";
|
|
649
|
+
return `\nAgent note: this actor was spawned directly and completed successfully. If this pattern looks reusable, ask the operator whether to save it as a durable recipe/tool under ~/.pi/agent/recipes with register_tool. Do not auto-save without confirmation.`;
|
|
650
|
+
}
|
|
651
|
+
|
|
613
652
|
export function formatRunTransitionMessage(transition: RunTransition): string {
|
|
614
653
|
const artifacts = formatNamedArtifacts(transition.artifacts);
|
|
615
654
|
const runFiles = formatRunFileList(getRunArtifacts(transition));
|
|
655
|
+
const persistenceSuggestion = formatRecipePersistenceSuggestion(transition);
|
|
616
656
|
if (transition.to === "done")
|
|
617
|
-
return `Run ${transition.run} completed successfully.${artifacts}${runFiles}\nUse inspect target=run:${transition.run} view=status or view=tail if the result needs inspection
|
|
657
|
+
return `Run ${transition.run} completed successfully.${artifacts}${runFiles}\nUse inspect target=run:${transition.run} view=status or view=tail if the result needs inspection.${persistenceSuggestion}`;
|
|
618
658
|
if (transition.to === "failed")
|
|
619
659
|
return `Run ${transition.run} failed.${artifacts}${runFiles}\nUse inspect target=run:${transition.run} view=status or view=tail for details.`;
|
|
620
660
|
if (transition.to === "cancelled")
|
package/lib/prompts.ts
CHANGED
|
@@ -29,7 +29,7 @@ export const ONBOARDING_SYSTEM_PROMPT = `pi-actors quick model:
|
|
|
29
29
|
- Recipe imports are local variables; imported recipes are definitions, not nested async runs; parent async:true creates one run.
|
|
30
30
|
- Use spawn/message/inspect for actor-level start/send/observe; avoid runtime/FIFO/outbox vocabulary in public guidance.
|
|
31
31
|
- Run state lives under ~/.pi/agent/tmp/pi-actors/runs; inspect status/tail/messages/mailbox/files/artifacts intentionally and avoid busy-polling.
|
|
32
|
-
- Maintain ~/.pi/agent/recipes like MEMORY.md for capabilities: keep useful tools, curate stale ones; packaged recipes are lower-priority components
|
|
32
|
+
- Maintain ~/.pi/agent/recipes like MEMORY.md for capabilities: keep useful tools, curate stale ones; packaged recipes are lower-priority components; offer to save successful direct spawn patterns only after confirmation.
|
|
33
33
|
- Foreground tools/templates fit short work; async recipes/runs fit subagents, services, fanout, media, and long pipelines.
|
|
34
34
|
- Long fanout = parent async recipe wrapping template(parallel:true) and imports; packaged fanout recipes bubble branch completion messages; grow recurring multi-agent workflows as packaged recipes/pipelines, not ad hoc external scripts.
|
|
35
35
|
- For deeper pi-actors guidance, inspect installed extension sources/docs/recipes; README and docs are not automatically in context.`;
|
package/lib/tools.ts
CHANGED
|
@@ -578,6 +578,7 @@ export function createSpawnToolDefinition<
|
|
|
578
578
|
: typeof input.recipe === "string"
|
|
579
579
|
? input.recipe
|
|
580
580
|
: undefined,
|
|
581
|
+
launch_source: "spawn",
|
|
581
582
|
ownerId: getRunOwnerId(ctx),
|
|
582
583
|
run_id: runId,
|
|
583
584
|
state_dir:
|
|
@@ -1301,6 +1302,7 @@ export function createRuntimeToolDefinition(
|
|
|
1301
1302
|
const meta = AsyncRuns.startRun(
|
|
1302
1303
|
{
|
|
1303
1304
|
...base,
|
|
1305
|
+
launch_source: "tool",
|
|
1304
1306
|
ownerId: getRunOwnerId(ctx),
|
|
1305
1307
|
run_id: runId,
|
|
1306
1308
|
tool: cfg.name,
|
package/package.json
CHANGED
package/skills/actors/SKILL.md
CHANGED
|
@@ -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.
|
|
5
|
+
version: 0.19.3
|
|
6
6
|
---
|
|
7
7
|
|
|
8
8
|
# Actors (pi-actors)
|
|
@@ -63,6 +63,7 @@ Rules:
|
|
|
63
63
|
|
|
64
64
|
- Use `file`/`recipe` for saved recipes; bare names resolve under `~/.pi/agent/recipes`.
|
|
65
65
|
- Use inline `template` for one-off experiments; promote useful repeats to recipes.
|
|
66
|
+
- When a directly spawned inline/ad hoc actor completes successfully and the follow-up suggests persistence, offer to save it as a recipe/tool; ask before writing `~/.pi/agent/recipes`.
|
|
66
67
|
- Use stable `as` names when you will inspect or message the actor later.
|
|
67
68
|
- `async: true` on the recipe is the detached run switch.
|
|
68
69
|
|
package/skills/swarm/SKILL.md
CHANGED