@llblab/pi-actors 0.45.0 → 0.46.0
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 +10 -6
- package/CHANGELOG.md +14 -1
- package/README.md +28 -12
- package/dist/fixtures/protocol/recipe-summary.json +1 -1
- package/dist/index.d.ts +1 -2
- package/dist/index.js +10 -110
- package/dist/lib/async-runs.d.ts +4 -1
- package/dist/lib/async-runs.js +22 -23
- package/dist/lib/automatic-review-runtime.d.ts +2 -0
- package/dist/lib/automatic-review-runtime.js +12 -5
- package/dist/lib/draft-sleep.js +0 -1
- package/dist/lib/extension-runtime.d.ts +21 -0
- package/dist/lib/extension-runtime.js +122 -0
- package/dist/lib/inspector.js +45 -7
- package/dist/lib/paths.d.ts +0 -1
- package/dist/lib/paths.js +0 -7
- package/dist/lib/prompts.d.ts +1 -1
- package/dist/lib/prompts.js +2 -2
- package/dist/lib/recipes-context.js +2 -2
- package/dist/lib/recipes-references.d.ts +24 -9
- package/dist/lib/recipes-references.js +152 -126
- package/dist/lib/runtime.d.ts +0 -1
- package/dist/lib/runtime.js +1 -3
- package/dist/lib/tools-inspect.d.ts +0 -1
- package/dist/lib/tools-inspect.js +35 -8
- package/dist/lib/tools-local.d.ts +2 -0
- package/dist/lib/tools-local.js +1 -1
- package/dist/lib/tools-spawn.d.ts +2 -0
- package/dist/lib/tools-spawn.js +24 -52
- package/dist/scripts/async-runner.mjs +0 -16
- package/dist/scripts/build-dist.mjs +13 -4
- package/dist/skills/actors/SKILL.md +6 -6
- package/dist/skills/actors/recipes/recipe-validate.json +11 -0
- package/{recipes/utility-coordinator-lock-snapshot.json → dist/skills/actors/recipes/resource-locker-snapshot.json} +1 -3
- package/dist/{recipes → skills/actors/recipes}/resource-locker.json +1 -3
- package/dist/{recipes/utility-run-ops-snapshot.json → skills/actors/recipes/run-ops-snapshot.json} +1 -3
- package/dist/skills/actors/recipes/run-summary.json +9 -0
- package/dist/{scripts/locker.mjs → skills/actors/scripts/resource-locker.mjs} +2 -23
- package/dist/skills/actors/scripts/run-utils.mjs +164 -0
- package/{scripts → dist/skills/actors/scripts}/validate-recipe.mjs +134 -18
- package/dist/skills/artifacts/SKILL.md +16 -0
- package/{recipes/pipeline-artifact-bundle.json → dist/skills/artifacts/recipes/bundle.json} +4 -4
- package/dist/{recipes/utility-artifact-write.json → skills/artifacts/recipes/file-write.json} +1 -3
- package/dist/{recipes/utility-artifact-manifest.json → skills/artifacts/recipes/manifest.json} +1 -3
- package/{recipes/pipeline-artifact-report.json → dist/skills/artifacts/recipes/report.json} +2 -2
- package/dist/{recipes/pipeline-artifact-write.json → skills/artifacts/recipes/write.json} +3 -3
- package/dist/skills/artifacts/scripts/artifact-utils.mjs +63 -0
- package/dist/skills/media/SKILL.md +16 -0
- package/dist/{recipes/pipeline-media-library.json → skills/media/recipes/library.json} +2 -2
- package/{recipes/music-player.json → dist/skills/media/recipes/player.json} +1 -3
- package/dist/{recipes/utility-playlist-build.json → skills/media/recipes/playlist-build.json} +1 -3
- package/dist/skills/media/scripts/media-utils.mjs +47 -0
- package/dist/{scripts → skills/media/scripts}/music-player.mjs +9 -3
- package/dist/skills/project-work/SKILL.md +16 -0
- package/dist/skills/project-work/recipes/changelog-section.json +11 -0
- package/{recipes/pipeline-docs-maintenance.json → dist/skills/project-work/recipes/docs-maintenance.json} +4 -4
- package/dist/skills/project-work/recipes/package-summary.json +9 -0
- package/{recipes/pipeline-release-readiness.json → dist/skills/project-work/recipes/release-readiness.json} +6 -6
- package/dist/{recipes/pipeline-release-summary.json → skills/project-work/recipes/release-summary.json} +5 -5
- package/{recipes/pipeline-repo-health.json → dist/skills/project-work/recipes/repo-health.json} +6 -6
- package/{recipes/pipeline-async-run-ops.json → dist/skills/project-work/recipes/run-ops.json} +3 -3
- package/dist/skills/project-work/recipes/skill-summary.json +11 -0
- package/dist/skills/project-work/scripts/project-utils.mjs +89 -0
- package/dist/skills/recipe-memory/SKILL.md +16 -0
- package/dist/skills/swarm/SKILL.md +4 -4
- package/{recipes/pipeline-architect-coordinator.json → dist/skills/swarm/recipes/architect.json} +5 -5
- package/{recipes/pipeline-checkpoint-continuation.json → dist/skills/swarm/recipes/checkpoint-continuation.json} +3 -3
- package/dist/{recipes/pipeline-development-tasking.json → skills/swarm/recipes/development-tasking.json} +4 -4
- package/dist/{recipes/lens-swarm.json → skills/swarm/recipes/lens-review.json} +1 -1
- package/dist/{recipes/pipeline-quorum-review.json → skills/swarm/recipes/quorum-review.json} +4 -4
- package/{recipes/pipeline-research-synthesis.json → dist/skills/swarm/recipes/research-synthesis.json} +6 -6
- package/{recipes/pipeline-review-readiness.json → dist/skills/swarm/recipes/review-readiness.json} +1 -1
- package/{recipes/subagents-prompts.json → dist/skills/swarm/recipes/subagent-prompts.json} +1 -1
- package/{recipes → dist/skills/swarm/recipes}/subagent-quorum.json +1 -1
- package/dist/{recipes → skills/swarm/recipes}/subagent-review-coordinator.json +6 -6
- package/docs/actor-inspector.md +4 -3
- package/docs/async-runs.md +2 -2
- package/docs/recipe-library.md +23 -23
- package/docs/releasing.md +2 -2
- package/docs/template-recipes.md +30 -14
- package/docs/tool-registry.md +2 -2
- package/fixtures/protocol/recipe-summary.json +1 -1
- package/index.ts +18 -112
- package/lib/async-runs.ts +47 -24
- package/lib/automatic-review-runtime.ts +16 -3
- package/lib/draft-sleep.ts +0 -1
- package/lib/extension-runtime.ts +158 -0
- package/lib/inspector.ts +56 -11
- package/lib/paths.ts +0 -7
- package/lib/prompts.ts +2 -2
- package/lib/recipes-context.ts +2 -2
- package/lib/recipes-references.ts +223 -134
- package/lib/runtime.ts +1 -5
- package/lib/tools-inspect.ts +42 -9
- package/lib/tools-local.ts +2 -0
- package/lib/tools-spawn.ts +37 -74
- package/package.json +3 -5
- package/scripts/async-runner.mjs +0 -16
- package/scripts/build-dist.mjs +13 -4
- package/skills/actors/SKILL.md +6 -6
- package/skills/actors/recipes/recipe-validate.json +11 -0
- package/{dist/recipes/utility-coordinator-lock-snapshot.json → skills/actors/recipes/resource-locker-snapshot.json} +1 -3
- package/{recipes → skills/actors/recipes}/resource-locker.json +1 -3
- package/{recipes/utility-run-ops-snapshot.json → skills/actors/recipes/run-ops-snapshot.json} +1 -3
- package/skills/actors/recipes/run-summary.json +9 -0
- package/{scripts/locker.mjs → skills/actors/scripts/resource-locker.mjs} +2 -23
- package/skills/actors/scripts/run-utils.mjs +164 -0
- package/{dist → skills/actors}/scripts/validate-recipe.mjs +134 -18
- package/skills/artifacts/SKILL.md +16 -0
- package/{dist/recipes/pipeline-artifact-bundle.json → skills/artifacts/recipes/bundle.json} +4 -4
- package/{recipes/utility-artifact-write.json → skills/artifacts/recipes/file-write.json} +1 -3
- package/{recipes/utility-artifact-manifest.json → skills/artifacts/recipes/manifest.json} +1 -3
- package/{dist/recipes/pipeline-artifact-report.json → skills/artifacts/recipes/report.json} +2 -2
- package/{recipes/pipeline-artifact-write.json → skills/artifacts/recipes/write.json} +3 -3
- package/skills/artifacts/scripts/artifact-utils.mjs +63 -0
- package/skills/media/SKILL.md +16 -0
- package/{recipes/pipeline-media-library.json → skills/media/recipes/library.json} +2 -2
- package/{dist/recipes/music-player.json → skills/media/recipes/player.json} +1 -3
- package/{recipes/utility-playlist-build.json → skills/media/recipes/playlist-build.json} +1 -3
- package/skills/media/scripts/media-utils.mjs +47 -0
- package/{scripts → skills/media/scripts}/music-player.mjs +9 -3
- package/skills/project-work/SKILL.md +16 -0
- package/skills/project-work/recipes/changelog-section.json +11 -0
- package/{dist/recipes/pipeline-docs-maintenance.json → skills/project-work/recipes/docs-maintenance.json} +4 -4
- package/skills/project-work/recipes/package-summary.json +9 -0
- package/{dist/recipes/pipeline-release-readiness.json → skills/project-work/recipes/release-readiness.json} +6 -6
- package/{recipes/pipeline-release-summary.json → skills/project-work/recipes/release-summary.json} +5 -5
- package/{dist/recipes/pipeline-repo-health.json → skills/project-work/recipes/repo-health.json} +6 -6
- package/{dist/recipes/pipeline-async-run-ops.json → skills/project-work/recipes/run-ops.json} +3 -3
- package/skills/project-work/recipes/skill-summary.json +11 -0
- package/skills/project-work/scripts/project-utils.mjs +89 -0
- package/skills/recipe-memory/SKILL.md +16 -0
- package/skills/swarm/SKILL.md +4 -4
- package/{dist/recipes/pipeline-architect-coordinator.json → skills/swarm/recipes/architect.json} +5 -5
- package/{dist/recipes/pipeline-checkpoint-continuation.json → skills/swarm/recipes/checkpoint-continuation.json} +3 -3
- package/{recipes/pipeline-development-tasking.json → skills/swarm/recipes/development-tasking.json} +4 -4
- package/{recipes/lens-swarm.json → skills/swarm/recipes/lens-review.json} +1 -1
- package/{recipes/pipeline-quorum-review.json → skills/swarm/recipes/quorum-review.json} +4 -4
- package/{dist/recipes/pipeline-research-synthesis.json → skills/swarm/recipes/research-synthesis.json} +6 -6
- package/{dist/recipes/pipeline-review-readiness.json → skills/swarm/recipes/review-readiness.json} +1 -1
- package/{dist/recipes/subagents-prompts.json → skills/swarm/recipes/subagent-prompts.json} +1 -1
- package/{dist → skills/swarm}/recipes/subagent-quorum.json +1 -1
- package/{recipes → skills/swarm/recipes}/subagent-review-coordinator.json +6 -6
- package/dist/recipes/utility-changelog-section.json +0 -13
- package/dist/recipes/utility-package-summary.json +0 -11
- package/dist/recipes/utility-run-summary.json +0 -11
- package/dist/recipes/utility-skill-summary.json +0 -13
- package/dist/recipes/utility-validate-recipe.json +0 -13
- package/dist/scripts/recipe-utils.mjs +0 -405
- package/dist/scripts/release-gates.mjs +0 -278
- package/recipes/utility-changelog-section.json +0 -13
- package/recipes/utility-package-summary.json +0 -11
- package/recipes/utility-run-summary.json +0 -11
- package/recipes/utility-skill-summary.json +0 -13
- package/recipes/utility-validate-recipe.json +0 -13
- package/scripts/recipe-utils.mjs +0 -405
- package/scripts/release-gates.mjs +0 -278
- /package/dist/{recipes/utility-validation-wrapper.json → skills/actors/recipes/command-validate.json} +0 -0
- /package/dist/{recipes/utility-jsonl-tail.json → skills/actors/recipes/jsonl-tail.json} +0 -0
- /package/dist/{recipes/utility-run-state-files.json → skills/actors/recipes/run-state-files.json} +0 -0
- /package/dist/{recipes/utility-playlist-scan.json → skills/media/recipes/playlist-scan.json} +0 -0
- /package/dist/{recipes/utility-changelog-head.json → skills/project-work/recipes/changelog-head.json} +0 -0
- /package/dist/{recipes/utility-git-log.json → skills/project-work/recipes/git-log.json} +0 -0
- /package/dist/{recipes/utility-git-status.json → skills/project-work/recipes/git-status.json} +0 -0
- /package/dist/{recipes/utility-markdown-index.json → skills/project-work/recipes/markdown-index.json} +0 -0
- /package/dist/{recipes → skills/recipe-memory/recipes}/draft-review.json +0 -0
- /package/dist/{recipes → skills/recipe-memory/recipes}/tool-review.json +0 -0
- /package/dist/{recipes → skills/swarm/recipes}/subagent-artifact.json +0 -0
- /package/dist/{recipes → skills/swarm/recipes}/subagent-checkpoint.json +0 -0
- /package/dist/{recipes → skills/swarm/recipes}/subagent-conflict-report.json +0 -0
- /package/dist/{recipes → skills/swarm/recipes}/subagent-contradiction-map.json +0 -0
- /package/dist/{recipes → skills/swarm/recipes}/subagent-critic.json +0 -0
- /package/dist/{recipes → skills/swarm/recipes}/subagent-evidence-map.json +0 -0
- /package/dist/{recipes → skills/swarm/recipes}/subagent-followup.json +0 -0
- /package/dist/{recipes → skills/swarm/recipes}/subagent-judge.json +0 -0
- /package/dist/{recipes → skills/swarm/recipes}/subagent-merge.json +0 -0
- /package/dist/{recipes → skills/swarm/recipes}/subagent-normalize.json +0 -0
- /package/dist/{recipes → skills/swarm/recipes}/subagent-plan.json +0 -0
- /package/dist/{recipes → skills/swarm/recipes}/subagent-preflight.json +0 -0
- /package/dist/{recipes → skills/swarm/recipes}/subagent-prompt.json +0 -0
- /package/dist/{recipes → skills/swarm/recipes}/subagent-review.json +0 -0
- /package/dist/{recipes → skills/swarm/recipes}/subagent-task-card.json +0 -0
- /package/dist/{recipes → skills/swarm/recipes}/subagent-tools.json +0 -0
- /package/dist/{recipes → skills/swarm/recipes}/subagent-verify.json +0 -0
- /package/{recipes/utility-validation-wrapper.json → skills/actors/recipes/command-validate.json} +0 -0
- /package/{recipes/utility-jsonl-tail.json → skills/actors/recipes/jsonl-tail.json} +0 -0
- /package/{recipes/utility-run-state-files.json → skills/actors/recipes/run-state-files.json} +0 -0
- /package/{recipes/utility-playlist-scan.json → skills/media/recipes/playlist-scan.json} +0 -0
- /package/{recipes/utility-changelog-head.json → skills/project-work/recipes/changelog-head.json} +0 -0
- /package/{recipes/utility-git-log.json → skills/project-work/recipes/git-log.json} +0 -0
- /package/{recipes/utility-git-status.json → skills/project-work/recipes/git-status.json} +0 -0
- /package/{recipes/utility-markdown-index.json → skills/project-work/recipes/markdown-index.json} +0 -0
- /package/{recipes → skills/recipe-memory/recipes}/draft-review.json +0 -0
- /package/{recipes → skills/recipe-memory/recipes}/tool-review.json +0 -0
- /package/{recipes → skills/swarm/recipes}/subagent-artifact.json +0 -0
- /package/{recipes → skills/swarm/recipes}/subagent-checkpoint.json +0 -0
- /package/{recipes → skills/swarm/recipes}/subagent-conflict-report.json +0 -0
- /package/{recipes → skills/swarm/recipes}/subagent-contradiction-map.json +0 -0
- /package/{recipes → skills/swarm/recipes}/subagent-critic.json +0 -0
- /package/{recipes → skills/swarm/recipes}/subagent-evidence-map.json +0 -0
- /package/{recipes → skills/swarm/recipes}/subagent-followup.json +0 -0
- /package/{recipes → skills/swarm/recipes}/subagent-judge.json +0 -0
- /package/{recipes → skills/swarm/recipes}/subagent-merge.json +0 -0
- /package/{recipes → skills/swarm/recipes}/subagent-normalize.json +0 -0
- /package/{recipes → skills/swarm/recipes}/subagent-plan.json +0 -0
- /package/{recipes → skills/swarm/recipes}/subagent-preflight.json +0 -0
- /package/{recipes → skills/swarm/recipes}/subagent-prompt.json +0 -0
- /package/{recipes → skills/swarm/recipes}/subagent-review.json +0 -0
- /package/{recipes → skills/swarm/recipes}/subagent-task-card.json +0 -0
- /package/{recipes → skills/swarm/recipes}/subagent-tools.json +0 -0
- /package/{recipes → skills/swarm/recipes}/subagent-verify.json +0 -0
package/AGENTS.md
CHANGED
|
@@ -36,14 +36,15 @@ Pi host
|
|
|
36
36
|
-> lib/observability.ts terminal + Trace-attention observation
|
|
37
37
|
-> lib/inspector*.ts owner-filtered actor-instance inspection
|
|
38
38
|
-> scripts/*.mjs process/service entrypoints
|
|
39
|
-
-> recipes
|
|
39
|
+
-> skills/*/recipes/* Skill-owned Recipe components
|
|
40
40
|
-> skills/* + docs/* agent and human guidance
|
|
41
41
|
```
|
|
42
42
|
|
|
43
|
-
`index.ts` wires Pi ports and must not own domain behavior. Keep the local TypeScript import graph acyclic.
|
|
43
|
+
`index.ts` wires Pi ports and must not own domain behavior. Keep the local TypeScript import graph acyclic. For architecture-affecting work, load and follow `.agents/skills/domain-dag/SKILL.md`; its validator is local agent tooling, not an npm, CI, or release gate.
|
|
44
44
|
|
|
45
45
|
## Key Domains
|
|
46
46
|
|
|
47
|
+
- `extension-runtime.ts`: low-level Pi session lifecycle, tool adaptation, and runtime service composition behind the thin `index.ts` event-registration root.
|
|
47
48
|
- `command-templates.ts`: portable synchronous execution graph.
|
|
48
49
|
- `recipes-references.ts`, `recipes-discovery.ts`, `recipe-control.ts`: Recipe resolution, imports, shadowing, and Control declarations.
|
|
49
50
|
- `async-runs.ts`: lifecycle facade.
|
|
@@ -57,17 +58,20 @@ Pi host
|
|
|
57
58
|
- `observability.ts`, `run-ui-runtime.ts`: Trace attention, terminal reconciliation, and Pi follow-up delivery.
|
|
58
59
|
- automatic draft/tool review domains: structurally redacted model review, journaled mutation, lineage, recovery, and explicit retry/reset safety.
|
|
59
60
|
|
|
60
|
-
|
|
61
|
+
The bundled Skill Recipe dependency DAG is `artifacts → actors, swarm`, `media → artifacts`, and `project-work → actors, artifacts, swarm`; `actors`, `swarm`, and `recipe-memory` have no cross-Skill Recipe dependencies.
|
|
62
|
+
|
|
63
|
+
Scripts remain self-contained when no non-script consumer justifies a TypeScript domain. Command-template script leaves infer `.js`/`.mjs` in order through Node, Bun, or `deno run` and `.sh` through Bash without shell evaluation. Helper-backed Skill Recipes self-locate through runtime-owned `{skill_dir}`. Recipes stay optional, composable, policy-light, and caller-configurable.
|
|
61
64
|
|
|
62
65
|
## Operating Principles
|
|
63
66
|
|
|
64
67
|
### Recipe
|
|
65
68
|
|
|
69
|
+
- Skill Recipe identity is `<active Skill name>/<Recipe filename stem>`; Recipe files have no top-level `name`. `SKILL.md` `name` is Pi host metadata matching the Skill directory, not a second pi-actors identity field.
|
|
66
70
|
- Recipe files may define args/defaults, imports, artifacts, command-template flags, and `control`.
|
|
67
71
|
- Declare actor-local actions only when a long-lived process implements them.
|
|
68
72
|
- Actions are lowercase, unique, and cannot use runtime-reserved lifecycle names.
|
|
69
73
|
- Removed communication-plane metadata fails explicitly; never translate it.
|
|
70
|
-
- User Recipes
|
|
74
|
+
- User Recipes are discovered only from the persistent user registry; Skill Recipes are exact components outside tool discovery. Explicit entry paths resolve from invocation `cwd`; relative imports resolve from their importing file.
|
|
71
75
|
- Files over 1 MiB, import depth over 32, and import cycles fail closed.
|
|
72
76
|
|
|
73
77
|
### Trace
|
|
@@ -137,8 +141,8 @@ When a deferred Run result gates the next step, wait for its terminal follow-up.
|
|
|
137
141
|
- Keep published text portable: use `~`, `<repo>`, or relative paths.
|
|
138
142
|
- Update `skills/actors/SKILL.md` when durable operating mechanics change.
|
|
139
143
|
- Keep `skills/swarm/SKILL.md` focused on multi-agent methodology rather than kernel internals.
|
|
140
|
-
- Recipe `description` is optional
|
|
141
|
-
- Before release run
|
|
144
|
+
- Recipe `description` is optional. Skill Recipe QA recursively validates direct filesystem-owned components and capability semantics with zero diagnostics or warnings; it does not enforce aesthetics or architecture policy.
|
|
145
|
+
- Before release run the normal product validation and dependency audit. Use the project-local Domain DAG Skill during architecture-affecting development, not as publication automation.
|
|
142
146
|
- `.github/workflows/release.yml` owns the immutable sequence reusable validation → npm Trusted Publisher publication/verification → GitHub Release convergence; follow [docs/releasing.md](docs/releasing.md).
|
|
143
147
|
- Keep npm publication tokenless: use the exact npm Trusted Publisher binding and job-scoped OIDC permission, never a long-lived npm token or token fallback.
|
|
144
148
|
- Until a stable version beyond `1.x`, prefer clean breaking simplification over compatibility aliases or renamed legacy abstractions.
|
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
## 0.46.0: Skill-Owned Capability Packs
|
|
4
|
+
|
|
5
|
+
- `Breaking Recipe Grammar`: File-backed identity now comes only from the filename; top-level Recipe `name`, nested Skill identities, JSON/Markdown stem collisions, bare references, and the old `std:` / `skill:` prefixes fail with migration guidance. Composition accepts exact `<active-skill>/<stem>` references or explicit `.json` / `.md` paths, with entry paths based at invocation cwd and relative imports based at their owning Recipe.
|
|
6
|
+
- `Skill-Owned Distribution`: All 58 bundled components move from the root Recipe library into six flat Pi Skills—Actors, Artifacts, Media, Project Work, Recipe Memory, and Swarm—with 67 explicit imports and an acyclic cross-Skill graph. Root and `dist` Recipe libraries, package-root discovery, fallback/shadowing, wrapper installation, and obsolete root capability helpers are removed; Skill components never auto-register as tools.
|
|
7
|
+
- `Scoped Resolution and Provenance`: Immutable active-Skill contexts are session-scoped and captured per Run. Recipe inspection distinguishes user registry capabilities, active Skill components, and explicit files while recording entry/import roles, filename stems, logical identities, Skill ownership, and alias ancestry without exposing private `source_file`, `{skill_dir}`, or `{recipe_dir}` values to model/Inspector surfaces.
|
|
8
|
+
- `Capability Safety`: Automatic review resolves exact package-owned `recipe-memory/*` components so user files cannot redirect reviewers. Helpers self-locate through runtime-owned `{skill_dir}`; Control, Trace, lifecycle fencing, review transactions, and the public `spawn`, `message`, `inspect`, `register_tool` plus Recipe/Trace/Control view contracts remain unchanged.
|
|
9
|
+
- `Validation and Architecture`: Recursive Skill QA validates direct identity, parse/import semantics, origins, Control, portable paths, and helper targets in source and installed packages. The custom release-gate and executable-style policy scanners are removed; CI runs product validation plus dependency audit, while a non-packaged project-local Domain DAG Skill supports architecture work without becoming a release gate.
|
|
10
|
+
- `Dogfood and Migration`: Source and installed tests execute repository health, release readiness, quorum review, artifact bundle, media player, and package-owned draft review through qualified Skill references, plus relative/absolute file imports and all breaking failures. Migrate `std:foo` to `owning-skill/foo`, `skill:foo/bar` to `foo/bar`, root Recipes to their owning Skill filename, and delete Recipe `name` fields.
|
|
11
|
+
|
|
12
|
+
## 0.45.1: Entrypoint and Release Policy
|
|
13
|
+
|
|
14
|
+
- `Architecture`: Keeps `index.ts` as a thin Pi event-registration and composition root while moving session lifecycle, runtime service composition, Skill discovery, and tool adaptation into the acyclic `extension-runtime.ts` domain.
|
|
15
|
+
- `Release Policy`: Raises the fixed shipped-source ceiling to 32,000 lines and rejects blank lines inside executable JavaScript/TypeScript blocks across the complete source and test tree while exempting structural declarations.
|
|
16
|
+
- `Package Metadata`: Moves the package image to the new raw-content endpoint to restore cross-origin loading.
|
|
4
17
|
|
|
5
18
|
## 0.45.0: Skill Recipe Standard Library
|
|
6
19
|
|
package/README.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# pi-actors
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+

|
|
4
|
+
|
|
5
|
+
Local Run kernel and persistent tool registry for [Pi](https://github.com/earendil-works/pi).
|
|
4
6
|
|
|
5
7
|
```text
|
|
6
8
|
Recipe --spawn--> Run
|
|
@@ -21,17 +23,18 @@ For local development:
|
|
|
21
23
|
pi install /path/to/pi-actors
|
|
22
24
|
```
|
|
23
25
|
|
|
24
|
-
The package contributes the extension,
|
|
26
|
+
The package contributes the extension and six capability-owning Skills for actors, artifacts, media, project work, Recipe memory, and swarm orchestration.
|
|
25
27
|
|
|
26
28
|
## Public Tools
|
|
27
29
|
|
|
28
30
|
### `spawn`
|
|
29
31
|
|
|
30
|
-
Create a Run from
|
|
32
|
+
Create a Run from an active-Skill Recipe, an explicit Recipe file, or an inline command template:
|
|
31
33
|
|
|
32
34
|
```text
|
|
33
35
|
spawn template="sleep 30" as=run:demo
|
|
34
|
-
spawn recipe=
|
|
36
|
+
spawn recipe=project-work/repo-health values={"repo":"/work/project","model":"provider/model"}
|
|
37
|
+
spawn recipe=media/player values={"source":"/music"} as=run:player
|
|
35
38
|
spawn template="make test" as=run:test
|
|
36
39
|
```
|
|
37
40
|
|
|
@@ -97,13 +100,25 @@ Example controlled Recipe:
|
|
|
97
100
|
"async": true,
|
|
98
101
|
"control": ["pause", "resume", "stop"],
|
|
99
102
|
"artifacts": { "state": "{state_dir}/player-state.json" },
|
|
100
|
-
"template": "{
|
|
103
|
+
"template": "{skill_dir}/scripts/player.mjs --state-dir {state_dir}"
|
|
101
104
|
}
|
|
102
105
|
```
|
|
103
106
|
|
|
104
107
|
Ordinary one-shot Recipes should omit `control`. Recipe imports compose definitions inside one Run; they do not create peer actors.
|
|
105
108
|
|
|
106
|
-
|
|
109
|
+
```json
|
|
110
|
+
{
|
|
111
|
+
"imports": {
|
|
112
|
+
"report": "artifacts/report",
|
|
113
|
+
"review": "swarm/quorum-review"
|
|
114
|
+
},
|
|
115
|
+
"template": [{ "name": "report" }, { "name": "review" }]
|
|
116
|
+
}
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
Skill Recipe identity is `<active Skill name>/<Recipe filename stem>`. Recipe files have no top-level `name`; the filename is identity. `SKILL.md` `name` remains Pi host metadata and matches the Skill directory—pi-actors adds no second Skill identity field.
|
|
120
|
+
|
|
121
|
+
References have two classes: exact active-Skill identities such as `project-work/repo-health`, and explicit `.json` / `.md` paths. Entry file paths resolve from invocation `cwd`; relative imports resolve from the importing Recipe's directory; absolute paths remain exact. File-backed Recipes receive immutable `{recipe_dir}` and Skill Recipes also receive `{skill_dir}`. Skill components never become tools automatically.
|
|
107
122
|
|
|
108
123
|
String command-template leaves execute directly without shell interpretation. Use template arrays for sequencing or an explicit trusted shell/script when shell semantics matter.
|
|
109
124
|
|
|
@@ -173,15 +188,16 @@ Open the owner-filtered TUI:
|
|
|
173
188
|
|
|
174
189
|
It presents actor instances through Recipe, Trace, and Control tabs, with source filtering, detail navigation, refresh, and generation-fenced Run kill.
|
|
175
190
|
|
|
176
|
-
##
|
|
191
|
+
## Skill Recipes
|
|
177
192
|
|
|
178
193
|
Useful entry points include:
|
|
179
194
|
|
|
180
|
-
- `
|
|
181
|
-
- `
|
|
182
|
-
- `
|
|
183
|
-
- `
|
|
184
|
-
- `
|
|
195
|
+
- `project-work/repo-health`
|
|
196
|
+
- `project-work/release-readiness`
|
|
197
|
+
- `swarm/quorum-review`
|
|
198
|
+
- `artifacts/bundle`
|
|
199
|
+
- `media/player` — controlled playback service
|
|
200
|
+
- `actors/resource-locker` — optional controlled resource-lock service
|
|
185
201
|
|
|
186
202
|
Validate Recipes with:
|
|
187
203
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* pi-actors — actor runtime and persistent local tool registry for pi.
|
|
3
3
|
* Zones: composition root, pi agent, actor runtime
|
|
4
|
-
*
|
|
5
|
-
* Wraps command templates as callable pi tools, stores durable user tools as recipe files, and exposes actor orchestration across reloads and sessions.
|
|
4
|
+
* Owns extension composition and Pi event registration, not domain behavior.
|
|
6
5
|
*/
|
|
7
6
|
import * as Pi from "./lib/pi.ts";
|
|
8
7
|
export default function toolRegistryExtension(pi: Pi.ExtensionAPI): void;
|
package/dist/index.js
CHANGED
|
@@ -1,117 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* pi-actors — actor runtime and persistent local tool registry for pi.
|
|
3
3
|
* Zones: composition root, pi agent, actor runtime
|
|
4
|
-
*
|
|
5
|
-
* Wraps command templates as callable pi tools, stores durable user tools as recipe files, and exposes actor orchestration across reloads and sessions.
|
|
4
|
+
* Owns extension composition and Pi event registration, not domain behavior.
|
|
6
5
|
*/
|
|
7
|
-
import * as
|
|
8
|
-
import * as CommandTemplates from "./lib/command-templates.js";
|
|
6
|
+
import * as ExtensionRuntime from "./lib/extension-runtime.js";
|
|
9
7
|
import * as InspectorCommand from "./lib/inspector-command.js";
|
|
10
|
-
import * as Paths from "./lib/paths.js";
|
|
11
|
-
import * as Pi from "./lib/pi.js";
|
|
12
|
-
import * as Prompts from "./lib/prompts.js";
|
|
13
|
-
import * as RecipesReferences from "./lib/recipes-references.js";
|
|
14
|
-
import * as RunUiRuntime from "./lib/run-ui-runtime.js";
|
|
15
|
-
import * as Runtime from "./lib/runtime.js";
|
|
16
|
-
import * as Temp from "./lib/temp.js";
|
|
17
|
-
import * as Tools from "./lib/tools.js";
|
|
18
|
-
import * as ToolsResponse from "./lib/tools-response.js";
|
|
19
8
|
export default function toolRegistryExtension(pi) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
getActiveContext: () => activeRunContext,
|
|
29
|
-
getRunOwnerId,
|
|
30
|
-
onRunEvent: automaticReview.schedule,
|
|
31
|
-
pi,
|
|
32
|
-
});
|
|
33
|
-
const actorToolDefinitions = new Map();
|
|
34
|
-
const withCurrentThinkingContext = (definition) => {
|
|
35
|
-
if (typeof definition.execute !== "function")
|
|
36
|
-
return definition;
|
|
37
|
-
const execute = definition.execute;
|
|
38
|
-
return {
|
|
39
|
-
...definition,
|
|
40
|
-
execute: async (...args) => {
|
|
41
|
-
const nextArgs = [...args];
|
|
42
|
-
const ctx = nextArgs[4];
|
|
43
|
-
if (ctx && typeof ctx === "object") {
|
|
44
|
-
nextArgs[4] = {
|
|
45
|
-
...ctx,
|
|
46
|
-
getThinkingLevel: () => pi.getThinkingLevel(),
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
try {
|
|
50
|
-
return ToolsResponse.spaceToolResult(await execute(...nextArgs));
|
|
51
|
-
}
|
|
52
|
-
catch (error) {
|
|
53
|
-
throw ToolsResponse.spaceToolError(error);
|
|
54
|
-
}
|
|
55
|
-
},
|
|
56
|
-
};
|
|
57
|
-
};
|
|
58
|
-
const runtime = Runtime.createAutoToolsRuntime({
|
|
59
|
-
configPath: Paths.EXTENSION_RUNTIME_PATHS.configPath,
|
|
60
|
-
exec: CommandTemplates.execCommandTemplate,
|
|
61
|
-
getActiveTools: () => pi.getActiveTools(),
|
|
62
|
-
registerTool: (definition) => {
|
|
63
|
-
const wrapped = withCurrentThinkingContext(definition);
|
|
64
|
-
actorToolDefinitions.set(wrapped.name, wrapped);
|
|
65
|
-
pi.registerTool(wrapped);
|
|
66
|
-
},
|
|
67
|
-
reservedToolNames: Tools.RESERVED_TOOL_NAMES,
|
|
68
|
-
setActiveTools: (toolNames) => pi.setActiveTools(toolNames),
|
|
69
|
-
});
|
|
70
|
-
const recipeReload = Runtime.createRecipeToolReloadWatcher(runtime);
|
|
71
|
-
pi.on("resources_discover", async () => {
|
|
72
|
-
const skillPaths = Paths.getExistingExtensionSkillPaths(import.meta.url);
|
|
73
|
-
if (skillPaths.length === 0)
|
|
74
|
-
return;
|
|
75
|
-
return { skillPaths };
|
|
76
|
-
});
|
|
77
|
-
pi.on("session_start", async (_event, ctx) => {
|
|
78
|
-
// Clear the pre-overlay widget after hot reloads from older pi-actors builds.
|
|
79
|
-
ctx.ui.setWidget("zz-pi-actors-comms", undefined);
|
|
80
|
-
activeRunContext = ctx;
|
|
81
|
-
runUiRuntime.close();
|
|
82
|
-
automaticReview.close();
|
|
83
|
-
recipeReload.close();
|
|
84
|
-
await Temp.prepareExtensionTempDir(Paths.EXTENSION_RUNTIME_PATHS.tempDir);
|
|
85
|
-
if (activeRunContext !== ctx)
|
|
86
|
-
return;
|
|
87
|
-
automaticReview.start(ctx);
|
|
88
|
-
runtime.loadTools(ctx);
|
|
89
|
-
runUiRuntime.start(ctx);
|
|
90
|
-
recipeReload.watch(ctx);
|
|
91
|
-
});
|
|
92
|
-
pi.on("agent_end", async (_event, ctx) => {
|
|
93
|
-
if (activeRunContext === ctx)
|
|
94
|
-
automaticReview.schedule();
|
|
95
|
-
});
|
|
96
|
-
pi.on("session_shutdown", async (event, ctx) => {
|
|
97
|
-
activeRunContext = undefined;
|
|
98
|
-
automaticReview.close();
|
|
99
|
-
recipeReload.close();
|
|
100
|
-
runUiRuntime.shutdown(event.reason, ctx);
|
|
101
|
-
});
|
|
102
|
-
InspectorCommand.registerActorInspectorCommand(pi, getRunOwnerId);
|
|
103
|
-
pi.on("before_agent_start", async (event) => {
|
|
104
|
-
RecipesReferences.setActiveSkillRecipeSources(event.systemPromptOptions.skills ?? []);
|
|
105
|
-
return {
|
|
106
|
-
systemPrompt: `${event.systemPrompt}\n\n${Prompts.ONBOARDING_SYSTEM_PROMPT}`,
|
|
107
|
-
};
|
|
108
|
-
});
|
|
109
|
-
Pi.registerToolDefinitions(pi, Tools.createCoreActorToolDefinitions({
|
|
110
|
-
configPath: Paths.EXTENSION_RUNTIME_PATHS.configPath,
|
|
111
|
-
getActiveTools: () => pi.getActiveTools(),
|
|
112
|
-
getRuntimeTool: (name) => Tools.resolveActiveRuntimeTool(name, runtime.getTools(), (activeName) => actorToolDefinitions.get(activeName)),
|
|
113
|
-
handleRuntimeControl: automaticReview.handleControl,
|
|
114
|
-
registryRuntime: runtime,
|
|
115
|
-
setActiveTools: (toolNames) => pi.setActiveTools(toolNames),
|
|
116
|
-
}).map(withCurrentThinkingContext));
|
|
9
|
+
const runtime = ExtensionRuntime.createActorExtensionRuntime(pi);
|
|
10
|
+
pi.on("resources_discover", async () => runtime.discoverResources(import.meta.url));
|
|
11
|
+
pi.on("session_start", async (_event, ctx) => runtime.onSessionStart(ctx));
|
|
12
|
+
pi.on("agent_end", async (_event, ctx) => runtime.onAgentEnd(ctx));
|
|
13
|
+
pi.on("session_shutdown", async (event, ctx) => runtime.onSessionShutdown(event.reason, ctx));
|
|
14
|
+
pi.on("before_agent_start", async (event, ctx) => runtime.beforeAgentStart(event.systemPrompt, event.systemPromptOptions.skills ?? [], ctx));
|
|
15
|
+
InspectorCommand.registerActorInspectorCommand(pi, runtime.getRunOwnerId);
|
|
16
|
+
runtime.registerCoreTools();
|
|
117
17
|
}
|
package/dist/lib/async-runs.d.ts
CHANGED
|
@@ -98,7 +98,10 @@ export interface AsyncRunMeta {
|
|
|
98
98
|
export { safeRunId } from "./runs-identity.ts";
|
|
99
99
|
export { resolveArtifactManifest } from "./runs-artifacts.ts";
|
|
100
100
|
export type { RunArtifactDeclaration, RunArtifactManifestEntry, } from "./runs-artifacts.ts";
|
|
101
|
-
export
|
|
101
|
+
export interface AsyncRunStartOptions {
|
|
102
|
+
skillContext?: RecipesReferences.ActiveSkillRecipeContext;
|
|
103
|
+
}
|
|
104
|
+
export declare function startRun(params: AsyncRunStartParams, cwd: string, options?: AsyncRunStartOptions): AsyncRunMeta;
|
|
102
105
|
export declare function getRunStatus(runOrDir: string): Record<string, unknown>;
|
|
103
106
|
export type { RunStateIndexEntry } from "./runs-index.ts";
|
|
104
107
|
export declare function listRunStateDirs(stateRoot?: string): string[];
|
package/dist/lib/async-runs.js
CHANGED
|
@@ -105,10 +105,11 @@ function resolveStateDir(params, run) {
|
|
|
105
105
|
function assertNoActiveRunState(stateDir) {
|
|
106
106
|
RunsStart.assertNoActiveRunState(stateDir, readJson, RUNNER_PATH);
|
|
107
107
|
}
|
|
108
|
-
function resolveRecipeFile(file) {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
108
|
+
function resolveRecipeFile(file, cwd, options) {
|
|
109
|
+
const path = RecipesReferences.resolveRecipeReferencePath(file, cwd, options.skillContext);
|
|
110
|
+
if (path)
|
|
111
|
+
return path;
|
|
112
|
+
throw new Error(`Recipe reference not found. Use <skill>/<recipe> or an explicit .json/.md file path: ${file}`);
|
|
112
113
|
}
|
|
113
114
|
function isMutableUsageRecipeFile(file) {
|
|
114
115
|
const userRoot = resolve(DEFAULT_RECIPE_ROOT);
|
|
@@ -116,12 +117,13 @@ function isMutableUsageRecipeFile(file) {
|
|
|
116
117
|
const relation = relative(userRoot, resolved);
|
|
117
118
|
return relation !== "" && !relation.startsWith("..") && !isAbsolute(relation);
|
|
118
119
|
}
|
|
119
|
-
function readRecipeFile(file) {
|
|
120
|
-
const path = resolveRecipeFile(file);
|
|
120
|
+
function readRecipeFile(file, cwd, options) {
|
|
121
|
+
const path = resolveRecipeFile(file, cwd, options);
|
|
121
122
|
const raw = RecipesReferences.readRawRecipeConfig(path);
|
|
122
123
|
const includeActorRecipeContext = raw?.actor_context !== false && raw?.actor_context !== "off";
|
|
123
124
|
const config = RecipesReferences.readResolvedRecipeConfig(path, [], {
|
|
124
125
|
includeActorRecipeContext,
|
|
126
|
+
skillContext: options.skillContext,
|
|
125
127
|
});
|
|
126
128
|
if (!config) {
|
|
127
129
|
throw new Error(`Template recipe must define template: ${path}`);
|
|
@@ -141,10 +143,10 @@ function getRunIdFromFile(file) {
|
|
|
141
143
|
const name = basename(file, extname(file));
|
|
142
144
|
return name || undefined;
|
|
143
145
|
}
|
|
144
|
-
function resolveStartParams(params) {
|
|
146
|
+
function resolveStartParams(params, cwd, options) {
|
|
145
147
|
if (!params.file)
|
|
146
148
|
return params;
|
|
147
|
-
const fileParams = readRecipeFile(params.file);
|
|
149
|
+
const fileParams = readRecipeFile(params.file, cwd, options);
|
|
148
150
|
return {
|
|
149
151
|
...fileParams,
|
|
150
152
|
...params,
|
|
@@ -239,23 +241,13 @@ function acquireStateStartLock(stateDir, options = {}) {
|
|
|
239
241
|
function prepareStateDirForStart(stateDir) {
|
|
240
242
|
RunsStart.prepareStateDirForStart(stateDir, readJson, RUNNER_PATH);
|
|
241
243
|
}
|
|
242
|
-
export function startRun(params, cwd) {
|
|
243
|
-
const startParams = resolveStartParams(params);
|
|
244
|
+
export function startRun(params, cwd, options = {}) {
|
|
245
|
+
const startParams = resolveStartParams(params, cwd, options);
|
|
244
246
|
const resolved = resolveRunTemplate(startParams);
|
|
245
247
|
const run = safeRunId(startParams.run_id);
|
|
246
248
|
const stateDir = resolveStateDir(startParams, run);
|
|
247
249
|
const recipeFile = startParams.file
|
|
248
|
-
? resolveRecipeFile(startParams.file)
|
|
249
|
-
: undefined;
|
|
250
|
-
const packagedRecipeRoot = resolve(Paths.getPackagedRecipeRoot());
|
|
251
|
-
const recipeRelation = recipeFile
|
|
252
|
-
? relative(packagedRecipeRoot, recipeFile)
|
|
253
|
-
: undefined;
|
|
254
|
-
const packagedRepo = startParams.defaults?.repo === "~/.pi/agent/extensions/pi-actors" &&
|
|
255
|
-
recipeRelation &&
|
|
256
|
-
!recipeRelation.startsWith("..") &&
|
|
257
|
-
!isAbsolute(recipeRelation)
|
|
258
|
-
? dirname(packagedRecipeRoot)
|
|
250
|
+
? resolveRecipeFile(startParams.file, cwd, options)
|
|
259
251
|
: undefined;
|
|
260
252
|
const argSpec = Schema.parseToolArgDeclarationList(startParams.args ?? []);
|
|
261
253
|
if (argSpec.error)
|
|
@@ -268,7 +260,6 @@ export function startRun(params, cwd) {
|
|
|
268
260
|
const values = Schema.normalizeRuntimeValues({
|
|
269
261
|
...argSpec.defaults,
|
|
270
262
|
...(startParams.defaults || {}),
|
|
271
|
-
...(packagedRepo ? { repo: packagedRepo } : {}),
|
|
272
263
|
...(startParams.values || {}),
|
|
273
264
|
run_id: run,
|
|
274
265
|
state_dir: stateDir,
|
|
@@ -306,7 +297,15 @@ export function startRun(params, cwd) {
|
|
|
306
297
|
const includeActorRecipeContext = startParams.actor_context !== false &&
|
|
307
298
|
startParams.actor_context !== "off";
|
|
308
299
|
const recipeContextRecords = recipeFile && includeActorRecipeContext
|
|
309
|
-
? RecipesReferences.buildRecipeContextRecords(recipeFile)
|
|
300
|
+
? RecipesReferences.buildRecipeContextRecords(recipeFile, options.skillContext).map((record, index) => index === 0 &&
|
|
301
|
+
startParams.launch_source === "tool" &&
|
|
302
|
+
record.source_kind === "explicit_file_recipe"
|
|
303
|
+
? {
|
|
304
|
+
...record,
|
|
305
|
+
logical_reference: record.name,
|
|
306
|
+
source_kind: "user_registry_capability",
|
|
307
|
+
}
|
|
308
|
+
: record)
|
|
310
309
|
: undefined;
|
|
311
310
|
if (recipeFile &&
|
|
312
311
|
isMutableUsageRecipeFile(recipeFile) &&
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* Owns automatic-review lifecycle wiring without owning review decisions or filesystem transactions.
|
|
5
5
|
*/
|
|
6
6
|
import type * as Pi from "./pi.ts";
|
|
7
|
+
import * as RecipesReferences from "./recipes-references.ts";
|
|
7
8
|
export interface AutomaticReviewRuntime {
|
|
8
9
|
close(): void;
|
|
9
10
|
handleControl(action: string, input: unknown): Record<string, unknown>;
|
|
@@ -15,4 +16,5 @@ export interface AutomaticReviewRuntimeDeps {
|
|
|
15
16
|
getRunOwnerId(ctx: Pi.ExtensionContext): string;
|
|
16
17
|
getThinkingLevel(): unknown;
|
|
17
18
|
}
|
|
19
|
+
export declare const PACKAGE_RECIPE_MEMORY_CONTEXT: RecipesReferences.ActiveSkillRecipeContext;
|
|
18
20
|
export declare function createAutomaticReviewRuntime(deps: AutomaticReviewRuntimeDeps): AutomaticReviewRuntime;
|
|
@@ -3,13 +3,20 @@
|
|
|
3
3
|
* Zones: session-bound review schedulers, silent reviewer launch adapters, review controls
|
|
4
4
|
* Owns automatic-review lifecycle wiring without owning review decisions or filesystem transactions.
|
|
5
5
|
*/
|
|
6
|
-
import {
|
|
6
|
+
import { fileURLToPath } from "node:url";
|
|
7
7
|
import * as AsyncRuns from "./async-runs.js";
|
|
8
8
|
import * as DraftSleep from "./draft-sleep.js";
|
|
9
9
|
import * as ModelContext from "./model-context.js";
|
|
10
10
|
import * as Paths from "./paths.js";
|
|
11
|
+
import * as RecipesReferences from "./recipes-references.js";
|
|
11
12
|
import * as ReviewControl from "./review-control.js";
|
|
12
13
|
import * as ToolReviewScheduler from "./tool-review-scheduler.js";
|
|
14
|
+
export const PACKAGE_RECIPE_MEMORY_CONTEXT = RecipesReferences.createActiveSkillRecipeContext([
|
|
15
|
+
{
|
|
16
|
+
name: "recipe-memory",
|
|
17
|
+
filePath: fileURLToPath(new URL("../skills/recipe-memory/SKILL.md", import.meta.url)),
|
|
18
|
+
},
|
|
19
|
+
]);
|
|
13
20
|
export function createAutomaticReviewRuntime(deps) {
|
|
14
21
|
let draftScheduler;
|
|
15
22
|
let toolScheduler;
|
|
@@ -56,14 +63,14 @@ export function createAutomaticReviewRuntime(deps) {
|
|
|
56
63
|
throw new Error("Draft review session changed before launch.");
|
|
57
64
|
}
|
|
58
65
|
return AsyncRuns.startRun({
|
|
59
|
-
file:
|
|
66
|
+
file: "recipe-memory/draft-review",
|
|
60
67
|
launch_source: "tool",
|
|
61
68
|
notification_policy: "silent",
|
|
62
69
|
ownerId: deps.getRunOwnerId(ctx),
|
|
63
70
|
policy_values: policyValues(ctx),
|
|
64
71
|
run_id: DraftSleep.draftSleepRunId(batch.batchId),
|
|
65
72
|
values: { input_path: batch.reviewerInputPath },
|
|
66
|
-
}, ctx.cwd);
|
|
73
|
+
}, ctx.cwd, { skillContext: PACKAGE_RECIPE_MEMORY_CONTEXT });
|
|
67
74
|
},
|
|
68
75
|
process: (state) => DraftSleep.processDraftSleepReview(state, {
|
|
69
76
|
getRunStatus: AsyncRuns.getRunStatus,
|
|
@@ -77,14 +84,14 @@ export function createAutomaticReviewRuntime(deps) {
|
|
|
77
84
|
throw new Error("Tool review session changed before launch.");
|
|
78
85
|
}
|
|
79
86
|
return AsyncRuns.startRun({
|
|
80
|
-
file:
|
|
87
|
+
file: "recipe-memory/tool-review",
|
|
81
88
|
launch_source: "tool",
|
|
82
89
|
notification_policy: "silent",
|
|
83
90
|
ownerId: deps.getRunOwnerId(ctx),
|
|
84
91
|
policy_values: policyValues(ctx),
|
|
85
92
|
run_id: ToolReviewScheduler.toolReviewRunId(batch.reviewId),
|
|
86
93
|
values: { input_path: batch.reviewerInputPath },
|
|
87
|
-
}, ctx.cwd);
|
|
94
|
+
}, ctx.cwd, { skillContext: PACKAGE_RECIPE_MEMORY_CONTEXT });
|
|
88
95
|
},
|
|
89
96
|
process: (state) => ToolReviewScheduler.processToolReviewResult(state, {
|
|
90
97
|
getRunStatus: AsyncRuns.getRunStatus,
|
package/dist/lib/draft-sleep.js
CHANGED
|
@@ -31,7 +31,6 @@ function readState(path) {
|
|
|
31
31
|
function defaultActiveTools(recipeRoot) {
|
|
32
32
|
const discovered = RecipesDiscovery.discoverRecipeSources([
|
|
33
33
|
{ root: recipeRoot, defaultTool: true, mutableUsage: true },
|
|
34
|
-
{ root: Paths.getPackagedRecipeRoot() },
|
|
35
34
|
]);
|
|
36
35
|
return [...discovered.active.values()]
|
|
37
36
|
.filter((entry) => existsSync(entry.path))
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pi actor extension runtime coordinator.
|
|
3
|
+
* Zones: extension session lifecycle, host tool adaptation, runtime service composition
|
|
4
|
+
* Owns low-level Pi lifecycle effects and tool wrapping without owning event registration.
|
|
5
|
+
*/
|
|
6
|
+
import * as Pi from "./pi.ts";
|
|
7
|
+
import * as RecipesReferences from "./recipes-references.ts";
|
|
8
|
+
export interface ActorExtensionRuntime {
|
|
9
|
+
beforeAgentStart(systemPrompt: string, skills: RecipesReferences.ActiveSkillRecipeSource[], ctx: Pi.ExtensionContext): {
|
|
10
|
+
systemPrompt: string;
|
|
11
|
+
};
|
|
12
|
+
discoverResources(metaUrl: string): {
|
|
13
|
+
skillPaths: string[];
|
|
14
|
+
} | undefined;
|
|
15
|
+
getRunOwnerId(ctx: Pi.ExtensionContext): string;
|
|
16
|
+
onAgentEnd(ctx: Pi.ExtensionContext): void;
|
|
17
|
+
onSessionShutdown(reason: string, ctx: Pi.ExtensionContext): void;
|
|
18
|
+
onSessionStart(ctx: Pi.ExtensionContext): Promise<void>;
|
|
19
|
+
registerCoreTools(): void;
|
|
20
|
+
}
|
|
21
|
+
export declare function createActorExtensionRuntime(pi: Pi.ExtensionAPI): ActorExtensionRuntime;
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pi actor extension runtime coordinator.
|
|
3
|
+
* Zones: extension session lifecycle, host tool adaptation, runtime service composition
|
|
4
|
+
* Owns low-level Pi lifecycle effects and tool wrapping without owning event registration.
|
|
5
|
+
*/
|
|
6
|
+
import * as AutomaticReviewRuntime from "./automatic-review-runtime.js";
|
|
7
|
+
import * as CommandTemplates from "./command-templates.js";
|
|
8
|
+
import * as Paths from "./paths.js";
|
|
9
|
+
import * as Pi from "./pi.js";
|
|
10
|
+
import * as Prompts from "./prompts.js";
|
|
11
|
+
import * as RecipesReferences from "./recipes-references.js";
|
|
12
|
+
import * as RunUiRuntime from "./run-ui-runtime.js";
|
|
13
|
+
import * as Runtime from "./runtime.js";
|
|
14
|
+
import * as Temp from "./temp.js";
|
|
15
|
+
import * as Tools from "./tools.js";
|
|
16
|
+
import * as ToolsResponse from "./tools-response.js";
|
|
17
|
+
export function createActorExtensionRuntime(pi) {
|
|
18
|
+
let activeRunContext;
|
|
19
|
+
const skillContextsBySession = new Map();
|
|
20
|
+
const getRunOwnerId = Pi.getSessionId;
|
|
21
|
+
const getSkillContext = (ctx) => skillContextsBySession.get(getRunOwnerId(ctx)) ??
|
|
22
|
+
RecipesReferences.EMPTY_ACTIVE_SKILL_RECIPE_CONTEXT;
|
|
23
|
+
const automaticReview = AutomaticReviewRuntime.createAutomaticReviewRuntime({
|
|
24
|
+
getActiveContext: () => activeRunContext,
|
|
25
|
+
getRunOwnerId,
|
|
26
|
+
getThinkingLevel: () => pi.getThinkingLevel(),
|
|
27
|
+
});
|
|
28
|
+
const runUiRuntime = RunUiRuntime.createRunUiRuntime({
|
|
29
|
+
getActiveContext: () => activeRunContext,
|
|
30
|
+
getRunOwnerId,
|
|
31
|
+
onRunEvent: automaticReview.schedule,
|
|
32
|
+
pi,
|
|
33
|
+
});
|
|
34
|
+
const actorToolDefinitions = new Map();
|
|
35
|
+
const withCurrentThinkingContext = (definition) => {
|
|
36
|
+
if (typeof definition.execute !== "function")
|
|
37
|
+
return definition;
|
|
38
|
+
const execute = definition.execute;
|
|
39
|
+
return {
|
|
40
|
+
...definition,
|
|
41
|
+
execute: async (...args) => {
|
|
42
|
+
const nextArgs = [...args];
|
|
43
|
+
const ctx = nextArgs[4];
|
|
44
|
+
if (ctx && typeof ctx === "object") {
|
|
45
|
+
nextArgs[4] = {
|
|
46
|
+
...ctx,
|
|
47
|
+
activeSkillRecipeContext: getSkillContext(ctx),
|
|
48
|
+
getThinkingLevel: () => pi.getThinkingLevel(),
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
try {
|
|
52
|
+
return ToolsResponse.spaceToolResult(await execute(...nextArgs));
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
throw ToolsResponse.spaceToolError(error);
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
const runtime = Runtime.createAutoToolsRuntime({
|
|
61
|
+
configPath: Paths.EXTENSION_RUNTIME_PATHS.configPath,
|
|
62
|
+
exec: CommandTemplates.execCommandTemplate,
|
|
63
|
+
getActiveTools: () => pi.getActiveTools(),
|
|
64
|
+
registerTool: (definition) => {
|
|
65
|
+
const wrapped = withCurrentThinkingContext(definition);
|
|
66
|
+
actorToolDefinitions.set(wrapped.name, wrapped);
|
|
67
|
+
pi.registerTool(wrapped);
|
|
68
|
+
},
|
|
69
|
+
reservedToolNames: Tools.RESERVED_TOOL_NAMES,
|
|
70
|
+
setActiveTools: (toolNames) => pi.setActiveTools(toolNames),
|
|
71
|
+
});
|
|
72
|
+
const recipeReload = Runtime.createRecipeToolReloadWatcher(runtime);
|
|
73
|
+
return {
|
|
74
|
+
beforeAgentStart(systemPrompt, skills, ctx) {
|
|
75
|
+
skillContextsBySession.set(getRunOwnerId(ctx), RecipesReferences.createActiveSkillRecipeContext(skills));
|
|
76
|
+
return {
|
|
77
|
+
systemPrompt: `${systemPrompt}\n\n${Prompts.ONBOARDING_SYSTEM_PROMPT}`,
|
|
78
|
+
};
|
|
79
|
+
},
|
|
80
|
+
discoverResources(metaUrl) {
|
|
81
|
+
const skillPaths = Paths.getExistingExtensionSkillPaths(metaUrl);
|
|
82
|
+
return skillPaths.length > 0 ? { skillPaths } : undefined;
|
|
83
|
+
},
|
|
84
|
+
getRunOwnerId,
|
|
85
|
+
onAgentEnd(ctx) {
|
|
86
|
+
if (activeRunContext === ctx)
|
|
87
|
+
automaticReview.schedule();
|
|
88
|
+
},
|
|
89
|
+
onSessionShutdown(reason, ctx) {
|
|
90
|
+
skillContextsBySession.delete(getRunOwnerId(ctx));
|
|
91
|
+
activeRunContext = undefined;
|
|
92
|
+
automaticReview.close();
|
|
93
|
+
recipeReload.close();
|
|
94
|
+
runUiRuntime.shutdown(reason, ctx);
|
|
95
|
+
},
|
|
96
|
+
async onSessionStart(ctx) {
|
|
97
|
+
skillContextsBySession.set(getRunOwnerId(ctx), RecipesReferences.EMPTY_ACTIVE_SKILL_RECIPE_CONTEXT);
|
|
98
|
+
ctx.ui.setWidget("zz-pi-actors-comms", undefined);
|
|
99
|
+
activeRunContext = ctx;
|
|
100
|
+
runUiRuntime.close();
|
|
101
|
+
automaticReview.close();
|
|
102
|
+
recipeReload.close();
|
|
103
|
+
await Temp.prepareExtensionTempDir(Paths.EXTENSION_RUNTIME_PATHS.tempDir);
|
|
104
|
+
if (activeRunContext !== ctx)
|
|
105
|
+
return;
|
|
106
|
+
automaticReview.start(ctx);
|
|
107
|
+
runtime.loadTools(ctx);
|
|
108
|
+
runUiRuntime.start(ctx);
|
|
109
|
+
recipeReload.watch(ctx);
|
|
110
|
+
},
|
|
111
|
+
registerCoreTools() {
|
|
112
|
+
Pi.registerToolDefinitions(pi, Tools.createCoreActorToolDefinitions({
|
|
113
|
+
configPath: Paths.EXTENSION_RUNTIME_PATHS.configPath,
|
|
114
|
+
getActiveTools: () => pi.getActiveTools(),
|
|
115
|
+
getRuntimeTool: (name) => Tools.resolveActiveRuntimeTool(name, runtime.getTools(), (activeName) => actorToolDefinitions.get(activeName)),
|
|
116
|
+
handleRuntimeControl: automaticReview.handleControl,
|
|
117
|
+
registryRuntime: runtime,
|
|
118
|
+
setActiveTools: (toolNames) => pi.setActiveTools(toolNames),
|
|
119
|
+
}).map(withCurrentThinkingContext));
|
|
120
|
+
},
|
|
121
|
+
};
|
|
122
|
+
}
|