@marcoscale98/pi-extensible-workflows 5.17.0-fork.1 → 6.2.1-fork.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.
Files changed (128) hide show
  1. package/CHANGELOG.md +145 -0
  2. package/README.md +2 -2
  3. package/dist/src/agent-execution.d.ts +43 -10
  4. package/dist/src/agent-execution.js +442 -162
  5. package/dist/src/background-widget.d.ts +5 -1
  6. package/dist/src/background-widget.js +5 -10
  7. package/dist/src/decoders.d.ts +2 -3
  8. package/dist/src/decoders.js +59 -37
  9. package/dist/src/execution.d.ts +6 -2
  10. package/dist/src/execution.js +48 -7
  11. package/dist/src/host-delivery.js +5 -8
  12. package/dist/src/host-navigator.js +5 -2
  13. package/dist/src/host-phases.d.ts +1 -0
  14. package/dist/src/host-recovery.d.ts +11 -8
  15. package/dist/src/host-recovery.js +14 -22
  16. package/dist/src/host-runtime.js +56 -5
  17. package/dist/src/host-view.d.ts +6 -1
  18. package/dist/src/host-view.js +46 -20
  19. package/dist/src/host.d.ts +2 -2
  20. package/dist/src/host.js +246 -118
  21. package/dist/src/index.d.ts +1 -2
  22. package/dist/src/index.js +1985 -1690
  23. package/dist/src/index.js.map +3 -3
  24. package/dist/src/paths.d.ts +8 -5
  25. package/dist/src/paths.js +24 -13
  26. package/dist/src/persistence.d.ts +1 -0
  27. package/dist/src/persistence.js +1 -0
  28. package/dist/src/pi-runtime-runner.js +4 -1
  29. package/dist/src/registry.d.ts +9 -7
  30. package/dist/src/registry.js +29 -71
  31. package/dist/src/runtime/agent-runner.d.ts +2 -0
  32. package/dist/src/script-tools.d.ts +27 -0
  33. package/dist/src/script-tools.js +87 -0
  34. package/dist/src/session-lease.d.ts +1 -1
  35. package/dist/src/session-lease.js +45 -11
  36. package/dist/src/settings.d.ts +19 -3
  37. package/dist/src/settings.js +63 -50
  38. package/dist/src/store.d.ts +3 -1
  39. package/dist/src/store.js +17 -1
  40. package/dist/src/trajectory.d.ts +12 -3
  41. package/dist/src/trajectory.js +32 -11
  42. package/dist/src/types.d.ts +129 -45
  43. package/dist/src/types.js +5 -8
  44. package/dist/src/utils.d.ts +21 -1
  45. package/dist/src/utils.js +46 -6
  46. package/dist/src/validation.d.ts +14 -3
  47. package/dist/src/validation.js +143 -87
  48. package/dist/starter/index.js +8 -11
  49. package/dist/starter/index.js.map +1 -1
  50. package/dist/starter/review-loop.d.ts +0 -13
  51. package/dist/starter/review-loop.js +8 -9
  52. package/dist/subagents/index.js +904 -956
  53. package/dist/subagents/index.js.map +3 -3
  54. package/dist/subagents/src/contracts.d.ts +48 -31
  55. package/dist/subagents/src/contracts.js +20 -9
  56. package/dist/subagents/src/index.d.ts +1 -1
  57. package/dist/subagents/src/index.js +14 -8
  58. package/dist/subagents/src/manager.js +52 -73
  59. package/dist/subagents/src/navigator.js +3 -14
  60. package/dist/subagents/src/view.d.ts +1 -1
  61. package/dist/subagents/src/view.js +15 -68
  62. package/dist/subagents/src/worktree.js +1 -1
  63. package/dist/trajectory/assets/index.html +35 -13
  64. package/dist/trajectory/index.js +576 -932
  65. package/dist/trajectory/index.js.map +3 -3
  66. package/dist/trajectory/src/assets/index.html +35 -13
  67. package/dist/trajectory/src/index.js +134 -104
  68. package/dist/trajectory/src/server.js +268 -27
  69. package/dist/trajectory/src/server.js.map +3 -3
  70. package/dist/trajectory/src/startup-mutex.d.ts +17 -0
  71. package/dist/trajectory/src/startup-mutex.js +172 -0
  72. package/examples/workflow-extension-template/README.md +4 -7
  73. package/examples/workflow-extension-template/extension.test.mjs +4 -8
  74. package/examples/workflow-extension-template/index.js +0 -3
  75. package/package.json +10 -10
  76. package/skills/pi-extensible-workflows/SKILL.md +12 -8
  77. package/src/agent-execution.ts +412 -164
  78. package/src/background-widget.ts +5 -11
  79. package/src/decoders.ts +51 -37
  80. package/src/execution.ts +46 -9
  81. package/src/host-delivery.ts +5 -8
  82. package/src/host-navigator.ts +4 -2
  83. package/src/host-phases.ts +1 -1
  84. package/src/host-recovery.ts +23 -28
  85. package/src/host-runtime.ts +44 -6
  86. package/src/host-view.ts +41 -16
  87. package/src/host.ts +229 -142
  88. package/src/index.ts +1 -2
  89. package/src/paths.ts +18 -9
  90. package/src/persistence.ts +1 -0
  91. package/src/pi-runtime-runner.ts +3 -1
  92. package/src/registry.ts +28 -64
  93. package/src/runtime/agent-runner.ts +2 -0
  94. package/src/script-tools.ts +76 -0
  95. package/src/session-lease.ts +34 -6
  96. package/src/settings.ts +56 -50
  97. package/src/store.ts +18 -2
  98. package/src/trajectory.ts +32 -15
  99. package/src/types.ts +82 -34
  100. package/src/utils.ts +42 -5
  101. package/src/validation.ts +121 -80
  102. package/starter/index.ts +0 -1
  103. package/starter/review-loop.ts +8 -9
  104. package/starter/roles/developer.md +0 -1
  105. package/starter/roles/oracle.md +0 -1
  106. package/starter/roles/researcher.md +0 -1
  107. package/starter/roles/reviewer.md +0 -1
  108. package/starter/roles/scout.md +0 -1
  109. package/subagents/README.md +10 -16
  110. package/subagents/src/contracts.ts +21 -11
  111. package/subagents/src/index.ts +17 -8
  112. package/subagents/src/manager.ts +48 -128
  113. package/subagents/src/navigator.ts +4 -13
  114. package/subagents/src/view.ts +16 -63
  115. package/subagents/src/worktree.ts +1 -1
  116. package/trajectory/src/assets/index.html +35 -13
  117. package/trajectory/src/index.ts +112 -91
  118. package/trajectory/src/server.ts +46 -10
  119. package/trajectory/src/startup-mutex.ts +127 -0
  120. package/dist/src/roles.d.ts +0 -70
  121. package/dist/src/roles.js +0 -325
  122. package/dist/starter/roles/developer.md +0 -6
  123. package/dist/starter/roles/oracle.md +0 -18
  124. package/dist/starter/roles/researcher.md +0 -20
  125. package/dist/starter/roles/reviewer.md +0 -19
  126. package/dist/starter/roles/scout.md +0 -18
  127. package/examples/workflow-extension-template/roles/reviewer.md +0 -4
  128. package/src/roles.ts +0 -326
package/CHANGELOG.md CHANGED
@@ -1,6 +1,151 @@
1
1
  # Changelog
2
2
  ## Unreleased
3
3
 
4
+ ## [6.2.1] - 2026-10-13
5
+
6
+ ### New capabilities
7
+
8
+ - Registered functions can create persistent agent handles with `context.agent.create({ name, ... })` and `handle.send(...)`, with the same rules as scripts. Handle journal identity is scoped by function invocation, branch, worktree, and name. The bundled `reviewLoop` now uses one persistent developer and a fresh reviewer each iteration.
9
+
10
+ ### Fixes
11
+
12
+ - Trajectory displays agent and system prompts as complete escaped plain text, so XML-style sections such as `<addendum>`, `<skills>`, and `<project_context>` remain visible instead of being interpreted as HTML inside Markdown. Browser regressions verify line breaks and safe rendering.
13
+ - `agent(...)` and `handle.send(...)` now deliver the supplied text as the whole user message, on first and later turns. The repeated Workflow/Agent/Phase/Parent header, ownership paragraph, and `Task:` wrapper are gone. The `workflow_result` once-per-turn contract moved into that tool's description, child ownership into the `agent` tool description, and retry or soft-budget notes into separate control text after the task (a steered message on local sessions, appended to the pane launch prompt on Herdr; custom transports that do not set `turnControlDelivered` get the steered message). The system prompt is unchanged, so prompt caching is unaffected.
14
+
15
+ ### Documentation and metadata
16
+
17
+ - Clarified that the workflow `model` option is optional; omitting it uses the configured defaults.
18
+ - Updated the core package description and keywords to include codemode scripts.
19
+
20
+ ## [6.2.0] - 2026-10-10
21
+
22
+ ### New capabilities
23
+
24
+ - Selecting a phase or registered function in the workflow navigator now shows total tokens, cost, and elapsed time across all its agents, including nested agents (#318).
25
+
26
+ ### Fixes
27
+
28
+ - Launch now checks static agent calls inside registered functions that the script calls by name, so an unknown model for a later agent fails before the workflow starts. A computed `outputSchema` no longer makes a call dynamic (#309).
29
+ - On Linux, session lease liveness uses the process start time from `/proc/<pid>/stat` instead of the `/proc/<pid>` entry time, so a live session owner is no longer reported dead (#307).
30
+ - In the wide workflow navigator, the details column follows the scrolled tree, so details for a selected node further down a long workflow stay visible (#317).
31
+ - Model references keep colon-bearing and namespaced model IDs, such as `openrouter/deepseek/deepseek-v4.1-flash:nitro:high`. The final `:` segment is read as a thinking level only when it names one, so `provider/model:turbo` now fails as `INVALID_METADATA` instead of `UNKNOWN_MODEL` (#314).
32
+ - Concurrent Trajectory starts in one agent directory now share one server whose lock always names the process answering `/health`. A lock whose owner is alive but does not answer within the startup budget, or a lock that cannot be read, is kept and the attach fails with a clear error, instead of a second server being started beside it. Process liveness is checked against the kernel start time, not the `/proc` entry time, and Trajectory sends SIGKILL only to a process whose recorded start time still matches; a stale server that cannot be confirmed stopped keeps its lock and fails the attach (#315).
33
+
34
+ ## [6.1.0] - 2026-10-08
35
+
36
+ **This minor version contains breaking changes.** Shipping them as 6.1.0 shortly after 6.0.0 is an explicit operator choice, not a SemVer-compliant version. Read the migration notes before upgrading.
37
+
38
+ ### Breaking changes
39
+
40
+ - Roles are now interpreted only by the explicitly enabled optional `@piewf/pi-ext-roles` extension. Core and CLI have no roles dependency, discovery, typed role fields, `/roles` export, `pi-role` bridge or legacy role paths. Without the plugin, unknown agent options are opaque JSON and ignored. The five fallback roles belong to the independent package.
41
+ - Generic `agentPreparationHooks` optionally validate original options with a schema, then prepare concrete configuration before model/resource validation. Workflow agents, handles, nested agents, standalone subagents and doctor share preparation and root/parent capability enforcement. Consumer selectors remain ordered defaults, not extra authorization ceilings.
42
+ - New runs freeze generic prepared configurations before dispatch. Workflow identity version 6 and standalone configuration version 1 reject previous formats without migration. Retry/resume reuse configuration; new identities resolve current settings. Extension code and skill/AGENTS/SYSTEM/APPEND bytes are reread, not frozen.
43
+ - Doctor uses `--agent-options <json>` and `agentInspection`, not role targets or `--role`. Bundles require explicit plugin resources/dependencies instead of role inference. Obsolete compatibility upgrade/warning checks are removed; generic and extension-owned regressions plus the local paired SDK/CLI harness replace their still-relevant coverage.
44
+ - Role descriptions append to Pi's structured prompt channel, preserving existing append instructions and dynamic provider/tool prefixes (#311); they never force the entire system prompt.
45
+
46
+ ### Migration
47
+
48
+ - To keep using `role` options, install `@piewf/pi-ext-roles` 0.2.0 or newer and enable it explicitly as a Pi extension next to workflows. Core and CLI no longer install or load it.
49
+ - Roles and shared settings are read only from the roles package paths: `~/.pi/agent/pi-ext-roles/{settings.json,roles/}` and authorized project `.pi/pi-ext-roles/{settings.json,roles/}`. Legacy workflow role paths are ignored; move files manually, nothing is rewritten.
50
+ - Runs persisted before 6.1.0 cannot be resumed or retried. Finish them before upgrading, then relaunch them as new runs.
51
+ - Role text is appended through Pi's structured system-prompt append channel. Only roles with `overrideSystemPrompt: true` replace the base prompt.
52
+ - `pi-role` is owned only by the independent `@piewf/pi-ext-roles` package, which works without workflows. Upgrade an old global `@piewf/cli` first; never overwrite the binary with `--force`.
53
+ - Prepared options stay bounded by root and parent tool ceilings, project trust and `excludeTools`; setup hooks cannot change the agent cwd.
54
+
55
+ ### Fixes
56
+
57
+ - Restored pre-6 behavior: `excludeTools` for workflow, nested and standalone agents, also in the `agent` and `subagents_run` tool schemas (exact names as in Pi, applied after preparation, bounded by parent ceilings and frozen with each logical agent's configuration; patterns and `workflow_result` are rejected, unknown names warn); `resources_discover` skills for root, nested and standalone agents, attributed per resource generation with Pi's path normalization; static preparation failures, including unavailable models and unknown roles, fail before shell, tool or run effects; nested children keep core error codes and their parent's structural scope under their own identity; unrelated extension load failures are CLI warnings; bundled factories run without a Pi API again and keep their module source.
58
+ - Launch inspection covers only completely static agent options (handles only when no send adds options) and stops on cancellation, also after the session lease. Nested children are new spawns of their parent's attempt, with identities per parent spawn: after retry or cold resume they prepare against current configuration.
59
+ - After a CLI extension load failure, every workflow registration must declare a `source` that is a loaded extension entry or a portable bundle module, or the CLI stops before running anything (a factory may register and then fail). Agent options that no such preparation hook declares in its `optionsSchema` fail with `INVALID_METADATA` instead of being ignored, also after paused resume, cold resume or retry. Setup hooks cannot reintroduce an excluded or outside-ceiling root tool as a same-named custom tool, and `excludeTools` names, own or inherited, also remove custom tools of those names.
60
+ - Preparation context adds `projectCwd` and `defaults.dynamicModelAliasNames`, so plugins can read launch-project configuration inside worktrees and order dynamic aliases below their own static aliases. A paused run resumed after an alias change prepares new agents with the refreshed aliases. A hook passing on a virtual `workflow/<alias>` root model gets its physical target.
61
+ - Setup hooks still cannot change the agent cwd, including to a project subdirectory; `SessionInput.cwd` is now read-only. This deliberate deviation from pre-6 prevents loading another directory's trust, settings and `.pi` resources.
62
+
63
+ ## [6.0.0] - 2026-10-07
64
+
65
+ ### Breaking changes
66
+
67
+ - Roles are owned by `@piewf/pi-ext-roles`, now a registry dependency of core and CLI. `registerWorkflowExtension({ roleDirectories })` is removed and fails with migration guidance. Register packaged roles separately with `registerRoleContribution(pi, { owner: import.meta.url, roleDirectories: ["./roles"] })`; keep workflow `source` for provenance and re-export portable bundles that used the removed field.
68
+ - The `pi-role` binary moves from `@piewf/cli` to `@piewf/pi-ext-roles`. Upgrade the old global CLI first, then install the roles package without forced binary overwrites. The retained `@piewf/cli/pi-role` import is a compatibility adapter, not the binary owner.
69
+ - Fallback roles no longer select models or supply workflow-specific model aliases. Configure a per-call model or an overriding role/shared alias explicitly when preserving an old fallback model choice.
70
+
71
+ ### Migration
72
+
73
+ - Workflow/subagent users receive the roles library automatically; a separately enabled roles plugin is not required. Move shared roles and settings to `~/.pi/agent/pi-ext-roles/` and `.pi/pi-ext-roles/` when ready. Workflow aliases/selectors remain consumer overrides. No user files are rewritten.
74
+ - Legacy workflow role paths and parser/resolver imports remain temporarily supported, with one TUI migration warning per session when applicable. No compatibility removal date is scheduled. Native `pi-role` does not read legacy workflow paths; migrate its files before using it.
75
+ - Native `pi-role` starts one Pi process from PATH. Role tool selectors control declared loadout, not a sandbox. Native tool flags remain ceilings; partial context scopes are unsupported unless suppressed with `--no-context-files`, and role/shared `extensionSettings` are ignored by the launcher. Workflow/subagent consumers retain settings delivery, partial context filtering, captured configuration, recovery and runtime ownership. See the [migration guide](https://vekexasia.github.io/pi-extensible-workflows/roles.html#migration).
76
+
77
+ ### Verification
78
+
79
+ - Package verification uses the published roles artifact, without a sibling checkout or local dependency staging. `scripts/verify-role-upgrade.py` exercises registry installation in an isolated Pi, the `5.19.1` to major-candidate upgrade, TUI/reload, legacy settings and role precedence, binary handover, migrated contributors and re-exported bundles against a local provider.
80
+
81
+ ## [5.19.1] - 2026-10-05
82
+
83
+ ### New capabilities
84
+
85
+ - Trajectory shows workflow script `shell()` and `tools.<name>()` calls: CALLS and the `script` Gantt lane share status and colours, with phase and timing. Tool arguments and results are not recorded in call state or shown in Trajectory (including live state and HTML exports/shares); tool errors keep only the code. The replay journal retains tool results unchanged. Shell calls keep inputs and output, with environment override names, not values. Calls are recorded without a count cap; tool metadata writes are best-effort, and journaled calls without finish timing show completed with unknown duration.
86
+
87
+ ## [5.19.0] - 2026-10-02
88
+
89
+ ### Breaking changes
90
+
91
+ - `tools` is a reserved workflow global: registering a workflow function named `tools` fails with `GLOBAL_COLLISION`. Rename the function.
92
+
93
+ ### New capabilities
94
+
95
+ - Workflow and subagent tools declare an `outputSchema` and return `structuredContent`, so Pi `codemode` scripts receive objects instead of JSON text. For example, `await tools.workflow_status({ runId })` resolves to `{ runId, workflowName, state, agents, ... }`. A completed foreground `workflow`, `workflow_retry`, or `workflow_resume` call resolves with the full `value`, even when the model sees only a result descriptor. Inside workflow agents, the child agent tools `agent` and `get_subagent_result` do the same, and Herdr-bridged tools keep their `outputSchema`.
96
+ - Workflow scripts call the launching session's tools directly as `await tools.<name>(args)`, through Pi's `ctx.executeTool()`, with the names and results of Pi `codemode`. Permission handlers apply, results are journaled for resume and retry, the live workflow item shows calls in flight, and an unknown tool fails the launch with `UNKNOWN_TOOL`. Failed calls reject with the new `TOOL_FAILED` code.
97
+ - `workflow_status`, `workflow_catalog`, and `subagents_inspect` carry the `readOnlyHint` tool annotation, so permission extensions that read annotations can skip confirming them.
98
+
99
+ ### Internal
100
+
101
+ - Build and test against Pi 1.0.0. `@piewf/cli` bundles Pi 1.0.0.
102
+
103
+ ## [5.18.0] - 2026-09-30
104
+
105
+ ### Breaking changes
106
+
107
+ - `pi-extensible-workflows` and `@piewf/herdr` require Pi 0.99.0 or later; their `@earendil-works/pi-coding-agent` peer dependency is now `>=0.99.0`. `@piewf/cli` bundles Pi 0.99.1.
108
+
109
+ ### New capabilities
110
+
111
+ - Global model aliases appear in `/model` and `--model` as virtual models named `workflow/<alias>`, for example `workflow/cheap-model`. The alias target is read from settings on every request, and workflow agents and subagents that inherit the session model run on that target. The thinking level selected in `/model` replaces the one in the alias. Project and extension-provided aliases are not listed, and new aliases need `/reload`.
112
+ - Workflow agents and standalone subagents load Pi's built-in `codemode`, `tool-search`, and `mcp` extensions, so they can reach the MCP servers from `mcp.json` through `codemode` or `tool_search`. `-builtin:<name>` in Pi settings still disables them. Workflow extension selectors name them `builtin:codemode`, `builtin:tool-search`, and `builtin:mcp`; a selector list that starts with `!*` needs `builtin:*` or those names to keep them.
113
+ - The global `codemodeTools` workflow setting limits which workflow and subagent tools Pi `codemode` scripts may call: `"all"` (default), `"read-only"` (`workflow_status`, `workflow_catalog`, and `subagents_inspect`), or `"none"`. The model still calls every tool directly. Changes apply after `/reload`.
114
+ - The agent tool ceiling includes the parent session's tools that only codemode scripts call or `tool_search` loads, such as MCP tools with the default exposure. Role and call tool selectors still restrict them.
115
+
116
+ ### Fixes
117
+
118
+ - Prompt inspection in `piewf doctor` and role inspection renders the system prompt again on Pi 0.99, including changes made by `before_agent_start` handlers.
119
+ - An agent that asks for a model of Pi's built-in `llama.cpp` provider fails with an error that explains why: Pi does not expose that extension to extension sessions. Declare the server as a provider in `models.json` instead.
120
+
121
+ ### Internal
122
+
123
+ - Build and test against Pi 0.99.1. Package verification ignores three `brace-expansion` advisories that come from the `npm-shrinkwrap.json` of `@earendil-works/pi-coding-agent@0.99.1`.
124
+
125
+ ## [5.17.2] - 2026-09-28
126
+
127
+ ### Breaking changes
128
+
129
+ - `subagents_inspect({})` lists only the runs of the current Pi session, matching `/subagents` and Trajectory. Pass `scope: "all"` to list every stored run as before. Lookup by `id` still resolves runs from any session ([#305](https://github.com/vekexasia/pi-extensible-workflows/pull/305)).
130
+
131
+ ### New capabilities
132
+
133
+ - `piewf doctor` inspects a role file before it is installed: a role ending in `.md`, such as `piewf doctor ./roles/reviewer.md`, is read as a file relative to the current working directory, while other values still name an installed role. A missing file reports `ROLE_FILE_NOT_FOUND` ([#303](https://github.com/vekexasia/pi-extensible-workflows/issues/303)).
134
+
135
+ ### Fixes
136
+
137
+ - `piewf doctor` no longer fails because of roles that another role overrides: it still reports their invalid frontmatter, but checks tools, models, and settings only for the roles that apply. A role tool missing from doctor's headless tool list is now a `ROLE_TOOL_INACTIVE` warning, because doctor cannot see tools that extensions add when a session starts and the runtime skips unavailable role tools. Role inspection and workflow agent sessions now skip the workflow host extensions of every installed copy of the package, so a Pi package installed next to `@piewf/cli` no longer fails with `Global name is already registered: reviewLoop` ([#302](https://github.com/vekexasia/pi-extensible-workflows/issues/302)).
138
+
139
+ ## [5.17.1] - 2026-09-26
140
+
141
+ ### Fixes
142
+
143
+ - Running workflow agents and standalone subagents show a fixed status glyph before their names and keep the activity spinner visible after `[running]`, even without a current activity label.
144
+
145
+ ### Internal
146
+
147
+ - Remove duplicated view and trajectory helpers, unused internal code, and tracked generated images. Preserve the public `pi-extensible-workflows/runtime` type exports.
148
+
4
149
  ## [5.17.0] - 2026-09-23
5
150
 
6
151
  ### New capabilities
package/README.md CHANGED
@@ -11,7 +11,7 @@ The repository [README](https://github.com/vekexasia/pi-extensible-workflows#rea
11
11
  ## Install
12
12
 
13
13
  Requires Node.js 22.19 or newer. This is trusted Pi host code with the same filesystem and process access as Pi.
14
- The core installation includes workflow orchestration, the `reviewLoop` starter for implementation-and-review cycles, packaged `developer`/`reviewer`/`scout`/`oracle`/`researcher` roles with ready-made slash commands (`/scout`, `/oracle`, `/review`, `/parallel-review`, `/review-loop`, `/deep-research`, and more), and durable standalone subagent tools. See the [Subagents guide](https://vekexasia.github.io/pi-extensible-workflows/subagents.html) for the bundled tools.
14
+ The core installation includes workflow orchestration, the `reviewLoop` starter for implementation-and-review cycles, ready-made slash commands (`/scout`, `/oracle`, `/review`, `/parallel-review`, `/review-loop`, `/deep-research`, and more), and durable standalone subagent tools. Role options in starters and slash commands require the separately enabled `@piewf/pi-ext-roles` Pi extension; core does not ship or interpret roles. See the [Subagents guide](https://vekexasia.github.io/pi-extensible-workflows/subagents.html) for the bundled tools.
15
15
  Trajectory live monitoring is included in the package. Restart existing Pi processes after upgrading the package so their publisher protocol matches the detached Trajectory server.
16
16
 
17
17
  ```sh
@@ -35,7 +35,7 @@ Launch with a non-empty `name` and exactly one of `script` or `scriptPath`. Regi
35
35
 
36
36
  ## Programmatic integration
37
37
 
38
- The package exports the workflow registry, runtime, persistence, validation, settings, role, lifecycle, and local Pi session APIs used by trusted hosts and extensions.
38
+ The package exports the workflow registry, runtime, persistence, validation, settings, generic agent preparation, lifecycle, and local Pi session APIs used by trusted hosts and extensions.
39
39
 
40
40
  Direct consumers of `createLocalPiSession()` receive a session with extensions already bound. Always `await session.dispose()` so `session_shutdown` runs before the native session is released; disposal is idempotent.
41
41
 
@@ -85,18 +85,17 @@ export interface PiResourceInspection {
85
85
  }[];
86
86
  readonly systemPromptSource?: string;
87
87
  }
88
- import type { AgentAccounting, AgentActivity, AgentContinuity, AgentIdentity, AgentResourcePolicy, AgentResourceSelectors, AgentSetup, AgentSetupSummary, AgentTransport, AgentTransportContext, ContextFileScope, JsonSchema, JsonValue, LiveSessionHandoff, ModelSpec, PreparedAgentSession, RegisteredAgentSetupHook, SessionInput, WorkflowAgentSession, WorkflowAgentSessionReference, WorkflowAgentSessionState, WorkflowExtensionSettings, WorkflowExtensionSettingsValidatorContext, WorkflowRunContext } from "./types.js";
89
- import { type AgentDefinition, type AgentState } from "./types.js";
88
+ import type { AgentPreparationContext, PreparedAgentConfiguration, RegisteredAgentPreparationHook, AgentAccounting, AgentActivity, AgentContinuity, AgentIdentity, AgentResourcePolicy, AgentResourceSelectors, AgentSetup, AgentSetupSummary, AgentTransport, AgentTransportContext, ContextFileScope, JsonSchema, JsonValue, LiveSessionHandoff, ModelSpec, PreparedAgentSession, RegisteredAgentSetupHook, SessionInput, WorkflowAgentSession, WorkflowAgentSessionReference, WorkflowAgentSessionState, WorkflowExtensionSettings, WorkflowExtensionSettingsValidatorContext, WorkflowRunContext } from "./types.js";
89
+ import { type AgentState } from "./types.js";
90
90
  import type { RunStore } from "./persistence.js";
91
- type AgentExecutionRunStore = Pick<RunStore, "recordSystemPrompt" | "validateWorktree" | "worktree" | "snapshotWorktree">;
92
- export type { AgentAccounting, AgentActivity, AgentInspectionMode, AgentSetup, AgentSetupContext, AgentSetupHook, AgentTransport, AgentTransportContext, PiRuntimeLaunchInfo, PreparedAgentSession, RegisteredAgentSetupHook, SessionInput, WorkflowAgentMessage, WorkflowAgentSession, WorkflowAgentSessionEvent, WorkflowAgentSessionReference, WorkflowAgentSessionState, WorkflowAgentSessionStats, WorkflowAgentTurnResult } from "./types.js";
91
+ type AgentExecutionRunStore = Pick<RunStore, "recordSystemPrompt" | "validateWorktree" | "worktree" | "snapshotWorktree"> & Partial<Pick<RunStore, "load" | "saveAgentConfiguration">>;
92
+ export type { AgentPreparation, AgentPreparationContext, PreparedAgentConfiguration, RegisteredAgentPreparationHook, AgentAccounting, AgentActivity, AgentInspectionMode, AgentSetup, AgentSetupContext, AgentSetupHook, AgentTransport, AgentTransportContext, PiRuntimeLaunchInfo, PreparedAgentSession, RegisteredAgentSetupHook, SessionInput, WorkflowAgentMessage, WorkflowAgentSession, WorkflowAgentSessionEvent, WorkflowAgentSessionReference, WorkflowAgentSessionState, WorkflowAgentSessionStats, WorkflowAgentTurnResult } from "./types.js";
93
93
  export interface AgentBudgetHooks {
94
94
  beforeAttempt(): void;
95
95
  beforeTurn(): void;
96
96
  afterTurn(accounting: AgentAccounting, final: boolean): void;
97
97
  instruction(): string | undefined;
98
98
  }
99
- export type { AgentDefinition } from "./types.js";
100
99
  export interface AgentProviderFailure {
101
100
  label: string;
102
101
  provider: string;
@@ -122,7 +121,6 @@ export interface AgentExecutionOptions {
122
121
  skills?: readonly string[];
123
122
  extensions?: readonly string[];
124
123
  effectiveTools?: readonly string[];
125
- role?: string;
126
124
  contextFiles?: readonly ContextFileScope[];
127
125
  schema?: JsonSchema;
128
126
  retries?: number;
@@ -136,31 +134,53 @@ export interface AgentExecutionOptions {
136
134
  agentIdentity?: AgentIdentity;
137
135
  inheritedExtensionSettings?: Readonly<WorkflowExtensionSettings>;
138
136
  agentNodeId?: string;
137
+ capabilities?: Readonly<{
138
+ tools: readonly string[];
139
+ skills: readonly string[];
140
+ extensions: readonly string[];
141
+ }>;
142
+ parentSkills?: readonly string[];
143
+ /** Tool names that ancestors excluded; with this agent's own `excludeTools`, they are removed from root and custom tools alike. */
144
+ inheritedExcludeTools?: readonly string[];
145
+ projectTrusted?: boolean;
146
+ configuration?: PreparedAgentConfiguration;
147
+ onConfiguration?: (configuration: PreparedAgentConfiguration) => void | Promise<void>;
139
148
  }
140
149
  export interface AgentExecutionRoot {
150
+ projectTrusted?: boolean;
141
151
  cwd: string;
142
152
  model: ModelSpec;
143
153
  tools: ReadonlySet<string>;
144
154
  extensionSettings?: Readonly<WorkflowExtensionSettings> | undefined;
145
155
  validateExtensionSettings?: (settings: Readonly<WorkflowExtensionSettings> | undefined, context: WorkflowExtensionSettingsValidatorContext) => void;
146
156
  onAgentSettings?: (agentNodeId: string, settings: Readonly<WorkflowExtensionSettings>) => void;
157
+ onAgentCapabilities?: (agentNodeId: string, capabilities: AgentPreparationContext["capabilities"], projectTrusted: boolean) => void;
147
158
  resourceSelectors?: AgentResourceSelectors;
148
- agentDefinitions?: Readonly<Record<string, AgentDefinition>>;
149
159
  agentDir?: string;
150
160
  additionalSkillPaths?: readonly string[];
151
161
  availableModels?: ReadonlySet<string>;
152
162
  knownModels?: ReadonlySet<string>;
153
163
  modelAliases?: Readonly<Record<string, string>>;
164
+ dynamicModelAliasNames?: readonly string[];
154
165
  blockedAliases?: ReadonlySet<string>;
155
166
  blockedAliasTargets?: Readonly<Record<string, string>>;
156
167
  settingsPath?: string;
157
168
  extensionSettingsPath?: string;
158
169
  runStore?: AgentExecutionRunStore;
159
170
  providerPause?: () => Promise<void>;
171
+ agentPreparationHooks?: readonly RegisteredAgentPreparationHook[];
160
172
  agentSetupHooks?: readonly RegisteredAgentSetupHook[];
161
173
  agentResourcePolicy?: () => AgentResourcePolicy | Promise<AgentResourcePolicy>;
162
174
  runContext?: Readonly<WorkflowRunContext>;
163
175
  onResourceWarning?: (message: string) => void;
176
+ /**
177
+ * Load failures this host tolerated and the identities of the extensions it did load. With failures, a non-core option
178
+ * counts as owned only by the schema of a preparation hook whose `source` is a loaded extension; others fail closed.
179
+ */
180
+ extensionLoad?: Readonly<{
181
+ errors: readonly string[];
182
+ loaded: readonly string[];
183
+ }>;
164
184
  }
165
185
  export interface AgentToolCallProgress {
166
186
  id: string;
@@ -222,7 +242,6 @@ export declare function getAgentAttempts(error: unknown): readonly AgentAttempt[
222
242
  export declare class WorkflowAgentExecutor {
223
243
  private readonly root;
224
244
  private readonly transport;
225
- private readonly warnedRoleTools;
226
245
  constructor(root: AgentExecutionRoot, transport?: AgentTransport);
227
246
  setRunContext(runContext: Readonly<WorkflowRunContext>): void;
228
247
  resolve(options: AgentExecutionOptions, inheritedTools?: readonly string[]): {
@@ -233,6 +252,7 @@ export declare class WorkflowAgentExecutor {
233
252
  systemPromptAppend: string;
234
253
  contextFiles?: readonly ContextFileScope[];
235
254
  };
255
+ prepare(options: AgentExecutionOptions, cwd?: string, signal?: AbortSignal, mode?: "execution" | "inspection"): Promise<PreparedAgentConfiguration>;
236
256
  execute(task: string, options: AgentExecutionOptions, signal?: AbortSignal, customTools?: readonly ToolDefinition[], setSteer?: (handler: (message: string) => void | Promise<void>) => void, beforeRetry?: () => void): Promise<AgentExecutionResult>;
237
257
  }
238
258
  export interface ScheduledAgentOptions {
@@ -245,7 +265,6 @@ export interface ScheduledAgentOptions {
245
265
  extensions?: readonly string[];
246
266
  worktreeOwner?: string;
247
267
  model?: string;
248
- role?: string;
249
268
  contextFiles?: readonly ContextFileScope[];
250
269
  schema?: JsonSchema;
251
270
  retries?: number;
@@ -255,6 +274,14 @@ export interface ScheduledAgentOptions {
255
274
  agentOptions?: Readonly<Record<string, JsonValue>>;
256
275
  agentIdentity?: AgentIdentity;
257
276
  extensionSettings?: Readonly<WorkflowExtensionSettings>;
277
+ capabilities?: Readonly<{
278
+ tools: readonly string[];
279
+ skills: readonly string[];
280
+ extensions: readonly string[];
281
+ }>;
282
+ projectTrusted?: boolean;
283
+ configuration?: PreparedAgentConfiguration;
284
+ inheritedExcludeTools?: readonly string[];
258
285
  }
259
286
  export type ScheduledAgentResult = {
260
287
  id: string;
@@ -297,7 +324,11 @@ type ScheduledNode = {
297
324
  resolveCompletion: () => void;
298
325
  task: () => Promise<void>;
299
326
  restored: boolean;
327
+ attemptCapabilities?: AgentPreparationContext["capabilities"];
328
+ attemptProjectTrusted?: boolean;
300
329
  steer?: (message: string) => void | Promise<void>;
330
+ /** Children spawned so far per label; numbers the occurrence of each child's own identity. */
331
+ childOccurrences?: Map<string, number>;
301
332
  };
302
333
  export type OwnershipRecord = {
303
334
  id: string;
@@ -317,6 +348,8 @@ export declare class FairAgentScheduler {
317
348
  addRun(runId: string, limit?: number, beforeLaunch?: () => void, extensionSettings?: Readonly<WorkflowExtensionSettings>): void;
318
349
  updateRunLimit(runId: string, limit: number): void;
319
350
  setRunExtensionSettings(runId: string, settings: Readonly<WorkflowExtensionSettings> | undefined): void;
351
+ setConfiguration(agentId: string, configuration: PreparedAgentConfiguration): Promise<void>;
352
+ setAttemptCapabilities(agentId: string, capabilities: AgentPreparationContext["capabilities"], projectTrusted: boolean): void;
320
353
  setExtensionSettings(agentId: string, settings: Readonly<WorkflowExtensionSettings>): void;
321
354
  spawn(runId: string, prompt: string, options: ScheduledAgentOptions, parentId?: string): {
322
355
  id: string;
@@ -331,7 +364,7 @@ export declare class FairAgentScheduler {
331
364
  attemptStarted(id: string): void;
332
365
  cancelRun(runId: string): Promise<void>;
333
366
  removeRun(runId: string): void;
334
- toolsFor(parentId: string, resolveTools?: (role: string | undefined, tools: readonly string[] | undefined, model: string | undefined, inheritedTools: readonly string[], skills: readonly string[] | undefined, extensions: readonly string[] | undefined) => readonly string[]): ToolDefinition[];
367
+ toolsFor(parentId: string): ToolDefinition[];
335
368
  snapshot(): readonly OwnershipRecord[];
336
369
  restoreRun(runId: string, limit: number, ownership: readonly OwnershipRecord[], beforeLaunch?: () => void, extensionSettings?: Readonly<WorkflowExtensionSettings>): void;
337
370
  flush(runId?: string): Promise<void>;