@vicary/pi-subagents 0.86.0 → 0.88.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/CHANGELOG.md +59 -0
- package/bundle/agents.js +3 -3
- package/bundle/child-tool-plan.js +2 -2
- package/bundle/{chunk-PYOAIN3V.js → chunk-2DIEL4WG.js} +2 -2
- package/bundle/{chunk-GJGTMLPE.js → chunk-3DT5X2QC.js} +483 -477
- package/bundle/{chunk-374MZFF4.js → chunk-3MFYKBKI.js} +23 -13
- package/bundle/{chunk-77ASNIEM.js → chunk-47ZN7NKR.js} +1 -1
- package/bundle/{chunk-QGO6HXHG.js → chunk-4MVDMA5C.js} +88 -64
- package/bundle/{chunk-3RKFH2UZ.js → chunk-6EUQPQY7.js} +31 -14
- package/bundle/{chunk-6VD7BGIC.js → chunk-6PR44R7E.js} +7 -2
- package/bundle/{chunk-DD22RXYJ.js → chunk-AOSILI5R.js} +200 -64
- package/bundle/{chunk-WHC2XHGF.js → chunk-BW5JLKIU.js} +174 -56
- package/bundle/{chunk-7ZUFN6ME.js → chunk-CKLZ5FGU.js} +2 -2
- package/bundle/{chunk-ZPY5QZCS.js → chunk-CYKNHFXB.js} +1 -1
- package/bundle/{chunk-YK3QYNLE.js → chunk-GDR2ILWY.js} +1 -1
- package/bundle/{chunk-7QA7ZA46.js → chunk-IZEKQEY4.js} +9 -9
- package/bundle/{chunk-CJHFDQFJ.js → chunk-JYHTDTOZ.js} +10 -6
- package/bundle/{chunk-NAFLUJ26.js → chunk-KXW62VBU.js} +1 -1
- package/bundle/{chunk-S2Q75LP3.js → chunk-L4YY2TOE.js} +1 -1
- package/bundle/{chunk-2DITXA3H.js → chunk-NVGQE2H2.js} +12 -12
- package/bundle/{chunk-BU6PFPVX.js → chunk-PJSOS2Q4.js} +12 -7
- package/bundle/{chunk-UR7OW5S7.js → chunk-RHYVKQQL.js} +11 -5
- package/bundle/{chunk-BGXEAYUM.js → chunk-SVIXQDIV.js} +20 -5
- package/bundle/{chunk-GLVJMI6R.js → chunk-TDJKY2NE.js} +14 -5
- package/bundle/{chunk-XOFYXQKZ.js → chunk-V7SZMS6W.js} +2 -2
- package/bundle/{chunk-NF7IEKBH.js → chunk-W2BZS6UC.js} +27 -13
- package/bundle/{chunk-5H4BICQZ.js → chunk-W6HIYD2Z.js} +1 -1
- package/bundle/{chunk-LGINOOY5.js → chunk-XIA5GSEU.js} +2 -2
- package/bundle/{chunk-QFLPV64W.js → chunk-XZXYPZUT.js} +46 -32
- package/bundle/chunk-YDZ7BZD5.js +523 -0
- package/bundle/{chunk-WN2E5XHN.js → chunk-YZPVALSQ.js} +30 -5
- package/bundle/control-channel.js +2 -2
- package/bundle/index.js +1 -1
- package/bundle/intercom-bridge.js +2 -2
- package/bundle/preflight.js +12 -10
- package/bundle/project-panes.js +3 -3
- package/bundle/workflow-resources.js +1 -1
- package/docs/agents.md +4 -4
- package/docs/configuration.md +14 -4
- package/docs/extension-api.md +2 -0
- package/docs/models.md +6 -2
- package/docs/observability.md +2 -0
- package/docs/tool-reference.md +5 -1
- package/package.json +3 -3
- package/skills/pi-subagents/SKILL.md +15 -6
- package/skills/pi-subagents/references/prompting-and-roles.md +1 -0
- package/src/agents/agent-management.d.ts +1 -0
- package/src/agents/agent-management.js +22 -10
- package/src/agents/agent-serializer.d.ts +2 -0
- package/src/agents/agent-serializer.js +1 -1
- package/src/agents/agents.d.ts +1 -0
- package/src/agents/agents.js +39 -14
- package/src/api/preflight.d.ts +3 -1
- package/src/api/preflight.js +2 -0
- package/src/extension/config.d.ts +9 -0
- package/src/extension/config.js +13 -0
- package/src/extension/index.js +8 -5
- package/src/extension/schemas.d.ts +4 -0
- package/src/extension/schemas.js +2 -0
- package/src/extension/tool-activation.js +20 -3
- package/src/runs/background/async-execution.d.ts +2 -1
- package/src/runs/background/async-execution.js +4 -2
- package/src/runs/background/async-resume.js +2 -1
- package/src/runs/background/async-retention.d.ts +0 -2
- package/src/runs/background/async-retention.js +11 -5
- package/src/runs/background/async-status.d.ts +2 -0
- package/src/runs/background/async-status.js +4 -0
- package/src/runs/background/run-child-session.d.ts +2 -2
- package/src/runs/background/run-child-session.js +4 -7
- package/src/runs/background/runner-aliases.js +15 -0
- package/src/runs/background/steering.d.ts +2 -11
- package/src/runs/background/steering.js +11 -6
- package/src/runs/background/subagent-runner.d.ts +0 -2
- package/src/runs/background/subagent-runner.js +73 -58
- package/src/runs/background/wait-subscriptions.js +124 -12
- package/src/runs/foreground/async-steering-action.js +24 -9
- package/src/runs/foreground/async-stop-action.d.ts +1 -1
- package/src/runs/foreground/async-stop-action.js +9 -1
- package/src/runs/foreground/execution.js +33 -15
- package/src/runs/foreground/prompt-audit.js +1 -0
- package/src/runs/foreground/subagent-executor.d.ts +2 -8
- package/src/runs/foreground/subagent-executor.js +57 -23
- package/src/runs/shared/async-status-projection.d.ts +2 -0
- package/src/runs/shared/async-status-projection.js +10 -0
- package/src/runs/shared/child-session.d.ts +5 -4
- package/src/runs/shared/child-session.js +64 -36
- package/src/runs/shared/herdr-placed-run.js +3 -2
- package/src/runs/shared/mcp-config-sources.d.ts +4 -1
- package/src/runs/shared/mcp-config-sources.js +1 -1
- package/src/runs/shared/mcp-direct-tool-allowlist.d.ts +0 -3
- package/src/runs/shared/mcp-direct-tool-allowlist.js +26 -17
- package/src/runs/shared/model-resolution.d.ts +19 -4
- package/src/runs/shared/model-resolution.js +50 -51
- package/src/runs/shared/subagent-prompt-runtime.js +14 -2
- package/src/runs/shared/supervisor-wait-timer.d.ts +16 -0
- package/src/runs/shared/supervisor-wait-timer.js +61 -0
- package/src/shared/artifacts.d.ts +1 -0
- package/src/shared/artifacts.js +132 -22
- package/src/shared/pruned-fork.js +2 -2
- package/src/shared/reported-progress.d.ts +1 -0
- package/src/shared/reported-progress.js +12 -0
- package/src/shared/status-format.d.ts +1 -0
- package/src/shared/status-format.js +1 -1
- package/src/shared/types.d.ts +23 -0
- package/src/shared/utils.d.ts +3 -1
- package/src/shared/utils.js +4 -0
- package/src/tui/render.js +33 -2
- package/src/watchdog/model-selection.js +2 -2
- package/src/watchdog/permission-arbiter.js +1 -0
- package/src/watchdog/review.d.ts +0 -5
- package/src/watchdog/review.js +4 -3
- package/src/workflows/scripted-workflow.d.ts +2 -0
- package/src/workflows/scripted-workflow.js +103 -39
- package/src/workflows/structured-workflow-scripts.d.ts +4 -3
- package/src/workflows/structured-workflow-scripts.js +32 -11
- package/src/workflows/workflow-resources.js +4 -4
- package/src/workflows/workflow-resume-claim.d.ts +2 -0
- package/src/workflows/workflow-resume-claim.js +1 -1
- package/src/workflows/workflow-resume.d.ts +1 -1
- package/src/workflows/workflow-resume.js +3 -1
- package/src/workflows/workflow-script-worker.js +3 -1
- package/bundle/chunk-GRJHIXYF.js +0 -235
package/bundle/preflight.js
CHANGED
|
@@ -2,22 +2,22 @@ import {
|
|
|
2
2
|
buildEffectiveSystemPrompt,
|
|
3
3
|
canPreferForkFromSnapshot,
|
|
4
4
|
resolveSubagentLaunchContext
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import "./chunk-
|
|
5
|
+
} from "./chunk-V7SZMS6W.js";
|
|
6
|
+
import "./chunk-XIA5GSEU.js";
|
|
7
7
|
import {
|
|
8
8
|
loadConfig
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-6PR44R7E.js";
|
|
10
10
|
import {
|
|
11
11
|
nestedResultsPath,
|
|
12
12
|
processTerminalCandidatePath,
|
|
13
13
|
processTerminalPath,
|
|
14
14
|
resultFilePath
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-3DT5X2QC.js";
|
|
16
16
|
import {
|
|
17
17
|
applyIntercomBridgeToAgent,
|
|
18
18
|
resolveIntercomBridge,
|
|
19
19
|
validateIntercomBridgeConfig
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-47ZN7NKR.js";
|
|
21
21
|
import {
|
|
22
22
|
AGENT_DEFINITION_PROJECTION_VERSION,
|
|
23
23
|
resolveLaunchBinding,
|
|
@@ -26,7 +26,7 @@ import {
|
|
|
26
26
|
import {
|
|
27
27
|
applyThinkingSuffix,
|
|
28
28
|
resolvePiLaunchToolPlan
|
|
29
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-3MFYKBKI.js";
|
|
30
30
|
import {
|
|
31
31
|
assertRequiredChildExtensionsAdmitted,
|
|
32
32
|
resolveRequiredChildExtensions
|
|
@@ -34,7 +34,7 @@ import {
|
|
|
34
34
|
import {
|
|
35
35
|
getArtifactPaths,
|
|
36
36
|
getArtifactsDir
|
|
37
|
-
} from "./chunk-
|
|
37
|
+
} from "./chunk-YDZ7BZD5.js";
|
|
38
38
|
import {
|
|
39
39
|
assertClaudeCodeModelScope,
|
|
40
40
|
assertThinkingWithinCeiling,
|
|
@@ -61,7 +61,7 @@ import {
|
|
|
61
61
|
resolveSkillsWithFallback,
|
|
62
62
|
resolveStepBehavior,
|
|
63
63
|
unknownAgentDiagnosticContext
|
|
64
|
-
} from "./chunk-
|
|
64
|
+
} from "./chunk-4MVDMA5C.js";
|
|
65
65
|
import {
|
|
66
66
|
DIRS,
|
|
67
67
|
SUBAGENT_LIFECYCLE_ARTIFACT_VERSION,
|
|
@@ -246,7 +246,8 @@ async function resolveSubagentLaunchContract(input) {
|
|
|
246
246
|
const modelOrigin = resolveModelOrigin({ explicitModel: input.model, agentModel: agent.model, parentModel: input.parentModel });
|
|
247
247
|
const primaryModel = externalRunner ? void 0 : resolveEffectiveSubagentModel(input.model, agent.model, input.parentModel, availableModels, preferredProvider, {
|
|
248
248
|
scope: modelScopes,
|
|
249
|
-
source: modelOrigin === "explicit" ? "explicit" : "inherited"
|
|
249
|
+
source: modelOrigin === "explicit" ? "explicit" : "inherited",
|
|
250
|
+
knownProviders: input.knownProviders
|
|
250
251
|
});
|
|
251
252
|
const effectiveThinkingConfig = input.thinking !== void 0 ? input.thinking : agent.thinking;
|
|
252
253
|
const thinkingCeiling = externalRunner ? void 0 : intersectThinkingCeilings(
|
|
@@ -257,7 +258,8 @@ async function resolveSubagentLaunchContract(input) {
|
|
|
257
258
|
const model = externalRunner ? void 0 : applyThinkingSuffix(resolveModelSelection(primaryModel, availableModels, preferredProvider, {
|
|
258
259
|
scope: modelScopes,
|
|
259
260
|
primaryModelFromParent: modelOrigin === "inherited" || inheritsParentModel(input.model, agent.model, input.parentModel),
|
|
260
|
-
origin: modelOrigin
|
|
261
|
+
origin: modelOrigin,
|
|
262
|
+
knownProviders: input.knownProviders
|
|
261
263
|
}).model, effectiveThinkingConfig, input.thinking !== void 0);
|
|
262
264
|
if (!externalRunner) {
|
|
263
265
|
try {
|
package/bundle/project-panes.js
CHANGED
|
@@ -8,10 +8,10 @@ import {
|
|
|
8
8
|
openProjectPane,
|
|
9
9
|
projectPaneBindingPath,
|
|
10
10
|
readProjectPaneBinding
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-2DIEL4WG.js";
|
|
12
12
|
import "./chunk-7J4ZXMY7.js";
|
|
13
|
-
import "./chunk-
|
|
14
|
-
import "./chunk-
|
|
13
|
+
import "./chunk-YDZ7BZD5.js";
|
|
14
|
+
import "./chunk-4MVDMA5C.js";
|
|
15
15
|
import "./chunk-JEZOSEWG.js";
|
|
16
16
|
import "./chunk-YFCK7H2S.js";
|
|
17
17
|
import "./chunk-QXASAHIA.js";
|
package/docs/agents.md
CHANGED
|
@@ -404,11 +404,11 @@ Use these fields when an agent should see more:
|
|
|
404
404
|
|-------|--------|
|
|
405
405
|
| `systemPromptMode: append` | Append the agent prompt to Pi's normal base prompt. |
|
|
406
406
|
| `inheritProjectContext: true` | Keep inherited repository instructions from files like `AGENTS.md` and `CLAUDE.md`. |
|
|
407
|
-
| `inheritGlobalContext: true` | Also keep the operator's global context file from the Pi config agent directory (such as `~/.pi/agent/AGENTS.md`). Defaults to `false
|
|
407
|
+
| `inheritGlobalContext: true` | Also keep the operator's global context file from the Pi config agent directory (such as `~/.pi/agent/AGENTS.md`). Defaults to `false`, or to `subagents.defaultInheritGlobalContext` when that is set. |
|
|
408
408
|
| `inheritSkills: true` | Let the child see Pi's discovered skills catalog. |
|
|
409
409
|
| `defaultContext: fork` | Prefer forked session context when a launch omits `context`; if the parent has no persisted session file or current leaf yet, the implicit default falls back to `fresh` without a failed first attempt. Explicit `context: "fork"` remains strict, and explicit `context: "fresh"` still wins. |
|
|
410
410
|
|
|
411
|
-
Builtin agents opt into repository instruction inheritance by default so they follow repo-specific rules out of the box, but global context remains excluded unless `inheritGlobalContext: true` is set. This changes the behavior of existing agents that previously received global context as part of `inheritProjectContext: true`. `delegate` also uses append mode because its job is orchestration inside the parent workflow.
|
|
411
|
+
Builtin agents opt into repository instruction inheritance by default so they follow repo-specific rules out of the box, but global context remains excluded unless `inheritGlobalContext: true` is set, per agent or for every agent with `subagents.defaultInheritGlobalContext: true` (see [models.md](models.md#global-context-default)). This changes the behavior of existing agents that previously received global context as part of `inheritProjectContext: true`. `delegate` also uses append mode because its job is orchestration inside the parent workflow.
|
|
412
412
|
|
|
413
413
|
These fields and `systemPromptMode` shape a fresh child's system prompt. A forked child (`context: "fork"`) sends its parent's whole system prompt instead, project context, global context, and skills included, and gets its agent prompt in its task message (see [fork context details](tool-reference.md#fork-context-details)).
|
|
414
414
|
|
|
@@ -478,7 +478,7 @@ Field notes:
|
|
|
478
478
|
| `thinking` | Appended as a `:level` suffix at runtime unless a suffix is already present. On the two Claude Code adapters it becomes `--effort`, and a suffix on `model` wins over it. |
|
|
479
479
|
| `systemPromptMode` | `replace` by default; `append` keeps Pi's base prompt. |
|
|
480
480
|
| `inheritProjectContext` | Keeps or strips inherited repository instruction blocks. |
|
|
481
|
-
| `inheritGlobalContext` | Keeps or strips the operator's global context file from the Pi config agent directory (e.g. `~/.pi/agent/AGENTS.md`). It has an effect only when `inheritProjectContext` is `true`; otherwise all context files are already disabled.
|
|
481
|
+
| `inheritGlobalContext` | Keeps or strips the operator's global context file from the Pi config agent directory (e.g. `~/.pi/agent/AGENTS.md`). It has an effect only when `inheritProjectContext` is `true`; otherwise all context files are already disabled. |
|
|
482
482
|
| `inheritSkills` | Keeps or strips Pi's discovered skills catalog. For in-process children this includes skills that loaded extensions add; herdr-placed children rely on Pi's `--no-skills`. |
|
|
483
483
|
| `defaultContext` | Optional `fresh` or `fork` launch-context preference. An implicit `fork` falls back to `fresh` when the parent has no persisted session file or current leaf; an explicit launch `context: "fork"` remains strict. |
|
|
484
484
|
| `skills` | Selects specific skills for the child, regardless of `inheritSkills`. |
|
|
@@ -593,7 +593,7 @@ Examples:
|
|
|
593
593
|
|
|
594
594
|
When [pi-mcp-adapter](https://github.com/nicobailon/pi-mcp-adapter) is not installed, `mcp:server` and `mcp:server/tool` entries resolve against Pi's built-in MCP. Name the server and tool as the server reports them: `mcp:my-docs/get-item` selects the tool Pi registers as `mcp__my_docs__get_item`. The server part may also use the `-`→`_` form of its name that Pi's MCP namespace uses, such as `mcp:my_docs`. The child connects the servers in Pi's `mcp.json` (the project's `.pi/mcp.json` only when the parent trusts the project) and gets only the selected tools, as direct tools, whatever exposure the server is configured with; tools configured as `hidden` cannot be selected. Servers that an extension adds with `pi.registerMcpServer()` work in background children, because the registering extension loads there too. They do not work in foreground children, which load no ambient extensions, so a foreground launch that selects one fails and says to use `async: true`. The child waits for the selected servers' current MCP connection attempts before its first prompt, then rejects the launch if any selected tool is missing or not available as a direct tool. Pi's MCP request timeout still bounds each connection; stopping, interrupting, timing out, or shutting down the child cancels the startup wait. An unrelated server does not delay this check.
|
|
595
595
|
|
|
596
|
-
When pi-mcp-adapter is installed, it keeps priority and provides the direct MCP tools. Subagents only receive direct MCP tools when `mcp:` entries are listed in their frontmatter; global `directTools: true` in the adapter's MCP config is not enough by itself. The generic `mcp` proxy tool can still be used for discovery when available. The adapter caches tool metadata at startup, so after connecting a new MCP server for the first time, restart Pi before relying on direct tools. Server `includeTools` and `excludeTools` policies are enforced while resolving cached metadata for children: both accept exact names and `*`/`?` glob patterns against raw, generated-resource, and server/short/mcp/none-prefixed names, with `excludeTools` taking precedence. `mcp:` entries must name servers from the adapter's configuration files. A server that exists only in the adapter's runtime snapshot (registered at runtime, not persisted) cannot be provided to a child: children are pi sessions inside the parent or the runner process, not `pi` processes that could receive an MCP config argument, so such a launch fails with an error saying that MCP tools must come from an ambient adapter extension in a background child. An `mcp:` entry named `subagent` does not authorize nested fanout; declare the builtin `subagent` tool or set `allowNestedSubagents: true`. If a resolved direct MCP name is missing from the child registry, pi-subagents keeps the launch failed under the strict allowlist and reports the registration mismatch; check the resolved names against what the host or pi-mcp-adapter actually registers before child startup.
|
|
596
|
+
When pi-mcp-adapter is installed, it keeps priority and provides the direct MCP tools. Subagents only receive direct MCP tools when `mcp:` entries are listed in their frontmatter; global `directTools: true` in the adapter's MCP config is not enough by itself. The generic `mcp` proxy tool can still be used for discovery when available. The adapter caches tool metadata at startup, so after connecting a new MCP server for the first time, restart Pi before relying on direct tools. Selectors for servers explicitly configured with `disabled: true` are skipped; unknown servers and enabled servers without matching cached tools still fail the launch. Server `includeTools` and `excludeTools` policies are enforced while resolving cached metadata for children: both accept exact names and `*`/`?` glob patterns against raw, generated-resource, and server/short/mcp/none-prefixed names, with `excludeTools` taking precedence. `mcp:` entries must name servers from the adapter's configuration files. A server that exists only in the adapter's runtime snapshot (registered at runtime, not persisted) cannot be provided to a child: children are pi sessions inside the parent or the runner process, not `pi` processes that could receive an MCP config argument, so such a launch fails with an error saying that MCP tools must come from an ambient adapter extension in a background child. An `mcp:` entry named `subagent` does not authorize nested fanout; declare the builtin `subagent` tool or set `allowNestedSubagents: true`. If a resolved direct MCP name is missing from the child registry, pi-subagents keeps the launch failed under the strict allowlist and reports the registration mismatch; check the resolved names against what the host or pi-mcp-adapter actually registers before child startup.
|
|
597
597
|
|
|
598
598
|
### Extension loading
|
|
599
599
|
|
package/docs/configuration.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
`pi-subagents` reads optional JSON config from `~/.pi/agent/extensions/subagent/config.json`. This page lists every key, plus the environment variables and the settings-file keys that affect config resolution.
|
|
4
4
|
|
|
5
|
-
Settings-level keys (`subagents.defaultModel`, `defaultProvider`, `defaultThinking`, `defaultExtensions`, `defaultSubagentOnlyExtensions`, `agentOverrides`, `machines`, `agentScanDirs`, `agentExcludeDirs`, `modelScope`, `disableThinking`, `disableBuiltins`, watchdog settings) live in Pi settings files, not this config file. `modelScope.agents.<name>` adds per-agent restrictions, `allow: ["inherit"]` permits the current parent model, and `allow: ["scoped"]` permits the parent session's scoped models (the parent model when the session is unscoped). See [models.md](models.md), [agents.md](agents.md), and [watchdog.md](watchdog.md).
|
|
5
|
+
Settings-level keys (`subagents.defaultModel`, `defaultProvider`, `defaultThinking`, `defaultExtensions`, `defaultSubagentOnlyExtensions`, `defaultInheritGlobalContext`, `agentOverrides`, `machines`, `agentScanDirs`, `agentExcludeDirs`, `modelScope`, `disableThinking`, `disableBuiltins`, watchdog settings) live in Pi settings files, not this config file. `modelScope.agents.<name>` adds per-agent restrictions, `allow: ["inherit"]` permits the current parent model, and `allow: ["scoped"]` permits the parent session's scoped models (the parent model when the session is unscoped). See [models.md](models.md), [agents.md](agents.md), and [watchdog.md](watchdog.md).
|
|
6
6
|
|
|
7
7
|
## Project root resolution (settings)
|
|
8
8
|
|
|
@@ -86,6 +86,14 @@ The recorded native `subagent` selection is restored on resume, reload, and tree
|
|
|
86
86
|
|
|
87
87
|
Some providers fix the tool list for a whole prompt, for example bridges that hand Pi's tools to another agent SDK. There `subagent` appears only on the next user prompt, not the next model request. Start Pi with `--exclude-tools subagents_enable` to keep `subagent` active from the start.
|
|
88
88
|
|
|
89
|
+
### First installation into an existing recorded session
|
|
90
|
+
|
|
91
|
+
If intact tool-selection history never declared this extension, `"auto"` keeps both `subagents_enable` and `subagent` absent. Installing the extension and running `/reload` alone does not add them.
|
|
92
|
+
|
|
93
|
+
To enable delegation in that session, merge `"toolActivation": "dynamic"` into the existing `~/.pi/agent/extensions/subagent/config.json` object; do not replace the file with the one-key example below. Restart Pi and resume the session, then ask the model to call the `subagents_enable({})` tool. This is a model tool, not a slash command.
|
|
94
|
+
|
|
95
|
+
Alternatively, merge `"toolActivation": "eager"` into the same config, restart Pi to remove the loader, then run `/reload` in the resumed session (see `"eager"` below).
|
|
96
|
+
|
|
89
97
|
## `toolActivation`
|
|
90
98
|
|
|
91
99
|
```json
|
|
@@ -96,9 +104,9 @@ Controls how a new parent session offers the `subagent` tool. The default is `"a
|
|
|
96
104
|
|
|
97
105
|
- `"auto"`: a new session starts with the `subagents_enable` loader only when its model can take a new tool mid-conversation. Otherwise it starts with `subagent` active and no loader, because calling the loader on such a model makes Pi resend the conversation in a form the provider may not have cached. A model qualifies when its Pi `compat` settings set `supportsMidConvoSystemMessages: true` and, for its API, `supportsMidConvoToolChanges: true` (`anthropic-messages`), `supportsMidConvoToolAdditions: true` (`openai-completions`), or `supportsAdditionalTools: true` or `supportsToolSearch: true` (`openai-responses`, `openai-codex-responses`, `azure-openai-responses`). Other APIs, missing settings, and no model do not qualify.
|
|
98
106
|
- `"dynamic"`: every new session starts with the loader, whatever the model. This was the behavior before `toolActivation` existed.
|
|
99
|
-
- `"eager"`: the loader is not registered,
|
|
107
|
+
- `"eager"`: the loader is not registered, and the extension does not change the tool selection. A new session or `/reload` makes `subagent` active; a resumed session whose recorded tools lack `subagent` stays without it until `/reload`. See the recovery steps above.
|
|
100
108
|
|
|
101
|
-
The choice is made
|
|
109
|
+
The choice is made only for a session with no messages, using the model selected before its first prompt. Switching models after that prompt does not change it. If a compaction that kept no tool checkpoint dropped the record of this choice, the session is decided again as a new session would be; tool selections recorded after that compaction (for `bg_wait` or another extension's tools) are not evidence that the choice survived. Under `"auto"`, resumed sessions keep the tools they recorded. `"dynamic"` also adds the loader to recorded sessions that did not have it. `"auto"` avoids only the loader's cache miss; other tool-list or provider changes can still miss the cache. An active `subagent` sends its full schema on every request. An invalid value is a config error, not a fallback to the default. Restart Pi after changing it.
|
|
102
110
|
|
|
103
111
|
## `toolDescriptionMode`
|
|
104
112
|
|
|
@@ -436,6 +444,8 @@ Forces depth-0 internal single, parallel, and chain runs into background mode an
|
|
|
436
444
|
|
|
437
445
|
Global default runtime deadline, in milliseconds, for foreground launches (single, parallel, chain, and workflow scripts) and plain single-agent async runs whenever no call-level `timeoutMs`/`maxRuntimeMs` applies. Without a configured or explicit deadline, these runs have no runtime deadline. For single-agent launches, selected agent frontmatter `timeoutMs` still wins. This only moves the *default*. Expiring this run-level deadline is terminal.
|
|
438
446
|
|
|
447
|
+
A run's deadline does not count time a child spends waiting for its supervisor's reply to a `contact_supervisor` decision or interview, or to an `intercom` ask; `progress_update` does not pause it, and the overall deadline of a workflow script stays wall-clock.
|
|
448
|
+
|
|
439
449
|
This deadline bounds the whole run. The wait for a single model response is bounded separately by Pi's `httpIdleTimeoutMs` setting (default 300000; `0` disables it), which Pi applies both as the SDK request timeout and as the undici header/body idle timeout. Detached async runners read the same setting from `~/.pi/agent/settings.json` and the project `.pi/settings.json` for their own HTTP dispatcher, so a local model that queues or prefills for longer than five minutes needs `httpIdleTimeoutMs` raised or disabled in Pi settings, and any configured run deadline must also allow enough time.
|
|
440
450
|
|
|
441
451
|
Use it when foreground orchestration or plain async single-agent runs need a default deadline. It does not set async composite top-level deadlines, and it does not replace async fan-out child deadlines.
|
|
@@ -724,7 +734,7 @@ Controls where subagent artifact files (inputs, outputs, transcripts, metadata)
|
|
|
724
734
|
|
|
725
735
|
This preference also controls the default workflow artifact directory used by scripted chaining. `"project"` uses `<cwd>/.pi/subagents/chain-runs/`; the directory keeps its legacy name for compatibility. The default `"session"` and `"temp"` use the user-scoped temp workflow artifact directory.
|
|
726
736
|
|
|
727
|
-
The `"session"` option uses the same directory that `cleanupAllArtifactDirs` already scans for age-based cleanup, so artifacts are still cleaned up automatically. Temporary workflow artifact directories are cleaned up separately after 24 hours.
|
|
737
|
+
The `"session"` option uses the same directory that `cleanupAllArtifactDirs` already scans for age-based cleanup, so artifacts are still cleaned up automatically: files older than `artifactConfig.cleanupDays` (default 7, `0` turns cleanup off) are removed, including those in nested folders such as workflow `outputs/`. `handoffs/` and `worktree-diffs/` are kept, because they record worktrees that can be kept longer than that. Temporary workflow artifact directories are cleaned up separately after 24 hours. The same setting covers forked children: each one writes a copy of the parent's session file to `<parent session file without .jsonl>/forks/<run id>/`, and once a day at extension load a copy is deleted when nothing has written to it for `cleanupDays` and its async run is not queued or running; the forked child's own artifacts, which live in that folder, go with it. Resuming a child after its copy is deleted fails with an error that says so.
|
|
728
738
|
|
|
729
739
|
When a project-scoped launch runs from an npm package directory, pi-subagents warns if package settings can include `.pi/subagents/` in the published package. Add `.pi/subagents/` to `.npmignore` (or `.gitignore` when no `.npmignore` exists), use a `files` allowlist that does not include `.pi/subagents/`, or select `"session"` or `"temp"`.
|
|
730
740
|
|
package/docs/extension-api.md
CHANGED
|
@@ -275,6 +275,8 @@ const result = await resolveSubagentLaunchContract({
|
|
|
275
275
|
cwd: ctx.cwd,
|
|
276
276
|
sessionRoot: "/tmp/my-extension-preflight-session-root",
|
|
277
277
|
availableModels: ctx.modelRegistry.getAvailable(),
|
|
278
|
+
// Every provider Pi knows, so `anthropic/...` never resolves to another provider's copy.
|
|
279
|
+
knownProviders: () => ctx.modelRegistry.getAll().map((model) => model.provider),
|
|
278
280
|
});
|
|
279
281
|
|
|
280
282
|
if (!result.ok) {
|
package/docs/models.md
CHANGED
|
@@ -164,6 +164,10 @@ Set `subagents.defaultSubagentOnlyExtensions` to give agents without a `subagent
|
|
|
164
164
|
|
|
165
165
|
The two defaults resolve independently, with an explicitly present project value winning over the user value. If both are set, `defaultExtensions` still disables ambient discovery and the child-only paths are loaded alongside its allowlist. Both reject non-arrays, non-string or blank entries with an error naming the setting and source file. Extension paths execute trusted code, so use project defaults only for trusted repositories and extensions.
|
|
166
166
|
|
|
167
|
+
## Global context default
|
|
168
|
+
|
|
169
|
+
Set `subagents.defaultInheritGlobalContext: true` to give every builtin, package, user and project agent your global context file (such as `~/.pi/agent/AGENTS.md`). An agent that declares `inheritGlobalContext` in its frontmatter keeps its own value, and `agentOverrides.<name>.inheritGlobalContext` still wins over both, so `false` in either place opts that agent out. A project value wins over the user value. The setting only matters for agents with `inheritProjectContext: true` (every builtin agent has it); without project context a child gets no context files at all. Runtime-registered agents keep their extension's value. A non-boolean value is rejected with an error naming the settings file.
|
|
170
|
+
|
|
167
171
|
## Inspecting the live mapping
|
|
168
172
|
|
|
169
173
|
To see what `pi-subagents` has actually loaded right now:
|
|
@@ -184,9 +188,9 @@ You do not have to spell a model exactly. Model ids are matched fuzzily against
|
|
|
184
188
|
- Case differences: `Claude-Sonnet-4` vs `claude-sonnet-4`
|
|
185
189
|
- Optional trailing date stamps: `claude-haiku-4-5-20251001` or `claude-haiku-4-5-2025-10-01` vs `claude-haiku-4-5`
|
|
186
190
|
|
|
187
|
-
Exact `provider/id` matches still win, and a qualified provider query never silently switches providers — it only matches within the named provider. Ambiguous bare ids that exist under multiple providers still require a provider prefix or the current session's provider to disambiguate.
|
|
191
|
+
Exact `provider/id` matches still win, and a qualified provider query never silently switches providers — it only matches within the named provider. This holds for providers you are not signed in to: without Anthropic credentials, `anthropic/claude-opus-4-8` fails with an error that names the OpenRouter copy (`openrouter/anthropic/claude-opus-4.8`) instead of running it. Ambiguous bare ids that exist under multiple providers still require a provider prefix or the current session's provider to disambiguate.
|
|
188
192
|
|
|
189
|
-
Registry ids that themselves contain `/` (Hugging Face `owner/name`) resolve the same way as Pi's main agent: `thinkingmachines/Inkling` becomes `huggingface/thinkingmachines/Inkling` when that id is unique or offered by the current session provider. A first path segment that
|
|
193
|
+
Registry ids that themselves contain `/` (Hugging Face `owner/name`) resolve the same way as Pi's main agent: `thinkingmachines/Inkling` becomes `huggingface/thinkingmachines/Inkling` when that id is unique or offered by the current session provider. A first path segment that names any provider Pi knows, signed in or not, still means `provider/id`.
|
|
190
194
|
|
|
191
195
|
## Model scope enforcement
|
|
192
196
|
|
package/docs/observability.md
CHANGED
|
@@ -16,6 +16,8 @@ Long-open `bash` attention notices identify the exact tool call and include stat
|
|
|
16
16
|
|
|
17
17
|
Live progress shows compact detail for single, chain, and parallel modes: a bounded one-line task, current tool, recent output, token counts, aggregate cost, duration, activity freshness, current-tool duration, and chain graph metadata when available. Workflow `label` metadata wins over raw task text in compact multi-child cards.
|
|
18
18
|
|
|
19
|
+
While a child runs, the first line of its latest successful `contact_supervisor` `progress_update` shows as a `progress:` row under its task, with the time since the report.
|
|
20
|
+
|
|
19
21
|
Press Pi's configured expand key (`Ctrl+O` by default) to expand the full streaming view with complete output per step.
|
|
20
22
|
|
|
21
23
|
Sequential chains show a flow line like `done scout → running worker`. Chains with parallel steps show per-step cards instead. Chain status uses `label` and `phase` metadata when present, while falling back to agent names for older chains.
|
package/docs/tool-reference.md
CHANGED
|
@@ -95,6 +95,7 @@ The `subagent` tool schema lists `agent`, `task`, `workflow`, `args`, `async`, `
|
|
|
95
95
|
| `options.view` | `fleet \| transcript` | - | Optional `status` view for the active fleet surface or transcript tail inspection. |
|
|
96
96
|
| `options.lines` | number | `80` | Maximum transcript lines for `action: "status"` with `options.view: "transcript"`; capped at 500. |
|
|
97
97
|
| `options.agentScope` | `user \| project \| both` | `both` | Agent discovery scope. Project wins on collisions. |
|
|
98
|
+
| `options.search` | string | - | With `action: "list"`, show only agents whose name, alias, or description contains this text (case-insensitive). |
|
|
98
99
|
| `options.capabilities` | boolean | `false` | With `action: "list"`, return compact prompt-free rows and `details.agentCapabilities` machine-readable records for each agent's declared/default routing capabilities. External CLI rows also include their command and passive local availability. |
|
|
99
100
|
|
|
100
101
|
### Execution parameters
|
|
@@ -105,7 +106,7 @@ The `subagent` tool schema lists `agent`, `task`, `workflow`, `args`, `async`, `
|
|
|
105
106
|
| `options.chatProgress` | `auto \| off \| live-card` | `auto` | Workflow chat projection. `auto` renders a live in-chat card only for watched foreground workflows in the same Git repository, including managed worktrees; it is off otherwise. Explicit `live-card` requires `async:false` and the same Git repository. Async workflows have no inline live card, so omit `chatProgress` or use `auto`/`off`; use `async:false` only when the parent must block. |
|
|
106
107
|
| `isolation` | `none \| worktree` | - | Alias kept at the top level; prefer `worktree`. Workflow child isolation. `none` runs in the shared cwd and does not need Git. `worktree` requires a managed Git worktree. Do not combine it with a contradictory `worktree` value. |
|
|
107
108
|
| `options.baseRef` | string | `HEAD` | `HEAD` or a supported named ref such as `refs/heads/release`, `refs/tags/v1`, or `origin/main`. Full 40/64-character commit IDs and revision expressions such as `HEAD~1` are unsupported. The ref must resolve to a commit at worktree allocation; omitted values default to `HEAD` resolved at that time. Source-checkout cleanliness is still checked. For a workflow script, set it on the outer request as a default or on an individual `runs.run`/`runs.all` child to override it. |
|
|
108
|
-
| `options.timeoutMs` | number | config `timeoutMs`, else none | Optional run-level max runtime in milliseconds. The top-level alias `maxRuntimeMs` is also accepted; both must agree. When omitted, the global [`timeoutMs`](configuration.md#timeoutms) config provides the default for foreground and plain single-agent async runs; otherwise no run-level deadline applies. Composite async runs (chains, parallel tasks, workflows) stay unbounded at the top level unless explicitly bounded. Expiration of a run-level deadline is terminal. |
|
|
109
|
+
| `options.timeoutMs` | number | config `timeoutMs`, else none | Optional run-level max runtime in milliseconds; time a child spends waiting for a supervisor reply (`contact_supervisor` decision or interview, `intercom` ask) does not count. The top-level alias `maxRuntimeMs` is also accepted; both must agree. When omitted, the global [`timeoutMs`](configuration.md#timeoutms) config provides the default for foreground and plain single-agent async runs; otherwise no run-level deadline applies. Composite async runs (chains, parallel tasks, workflows) stay unbounded at the top level unless explicitly bounded. Expiration of a run-level deadline is terminal. |
|
|
109
110
|
| `options.toolTimeoutMs` | number | fast-tool default | Optional positive hard per-tool-call deadline in milliseconds. Precedence: call value → agent frontmatter → config → `PI_SUBAGENT_TOOL_TIMEOUT_MS`. The timer starts on `tool_execution_start`, clears on the matching `tool_execution_end`, and terminates the run with `timedOut: true` if the tool remains open. When omitted, known-fast built-in tools get a five-minute default; long-running tools get attention notices but no hard default. It never extends the run deadline; `contact_supervisor`, `intercom`, and `bg_wait` are exempt. |
|
|
110
111
|
| `options.checkpointBeforeDeadlineMs` | number | none | Async single-agent runs only. The runner requests that the child "checkpoint and stop" this many milliseconds before the run deadline (finish the current tool call, report changed files, build/test state, remaining work, commit/PR state; start no new work). This best-effort steer uses the normal steering lifecycle at the next tool boundary, so the receipt is visible in status and events; the ordinary deadline kill still applies. Precedence: call value → config `checkpointBeforeDeadlineMs`. Disarmed when the deadline leaves under one second before the checkpoint. |
|
|
111
112
|
| `options.toolBudget` | object | none | Optional child tool-call budget `{ soft?, hard, block? }`: `hard` is a positive integer and `soft`, if set, is a positive integer no greater than `hard`. At `soft` the child is nudged to finalize. After `hard`, configured tools are blocked; `block` defaults to `read`, `grep`, `find`, and `ls`, and accepts either a nonempty array of tool names or `"*"` for every tool call. Final assistant text is never blocked. |
|
|
@@ -210,6 +211,7 @@ Agent definitions are not loaded into context by default. Management actions let
|
|
|
210
211
|
{ action: "list" }
|
|
211
212
|
{ action: "list", options: { agentScope: "project" } }
|
|
212
213
|
{ action: "list", options: { capabilities: true } }
|
|
214
|
+
{ action: "list", options: { search: "review" } }
|
|
213
215
|
{ action: "get", agent: "scout" }
|
|
214
216
|
{ action: "models" }
|
|
215
217
|
{ action: "models", agent: "reviewer" }
|
|
@@ -252,6 +254,7 @@ Agent definitions are not loaded into context by default. Management actions let
|
|
|
252
254
|
|
|
253
255
|
Rules:
|
|
254
256
|
|
|
257
|
+
- `action: "list"` shows at most 30 agents, then a `+N more` line pointing at `options.search`; `details.agentCapabilities` still covers every match.
|
|
255
258
|
- `options.capabilities: true` changes `action: "list"` to compact one-line rows and adds `details.agentCapabilities: { agents, restrictedCount, capabilityCeilingSources? }`. Each agent row includes source, aliases, runner type/capabilities, tools, MCP direct tools, mutation tools, model/thinking, default async/timeout, declared acceptance policy/role, output path/mode, skills/extensions, and whether the current capability ceiling allows execution. External CLI rows include `runner.command`, `runner.available`, and a bounded `runner.unavailableReason` when passive PATH/PATHEXT/X_OK lookup cannot find the command. It never includes an agent's system prompt. Rows show declared/default capabilities and command discoverability, not authentication, version compatibility, or successful launch; launch preflight remains authoritative.
|
|
256
259
|
- `create` uses `config.scope`, not `agentScope`.
|
|
257
260
|
- `config.name` is the local frontmatter name; optional `config.package` registers the runtime name as `{package}.{name}` and is saved as separate `name` and `package` frontmatter.
|
|
@@ -392,6 +395,7 @@ Commands remain owned by the child session. Normal completion with unfinished co
|
|
|
392
395
|
- `/subagents-stop` without an id opens a selector with confirmation when a TUI is available. Use `↑`/`↓` or `j`/`k` to move through the selector. When two or more current-session async runs are active, the first row is "stop all", which stops each of them after one confirmation and leaves scheduled runs alone.
|
|
393
396
|
- In non-TUI contexts the slash command prints exact `subagent({ action: "stop", id })` and `/subagents-stop <id>` commands.
|
|
394
397
|
- Pass a child id to stop one child of a multi-child async run or workflow while the rest continue: `/subagents-stop <run-id> <child-id>` (equivalent to `subagent({ action: "stop", id, childId })`). Child ids come from status output, the async status snapshot, or `/subagents-inspect-rpc` replies. Only pending or running children are stoppable; the request is rejected for anything else instead of widening to a run-level stop.
|
|
398
|
+
- `subagent({ action: "stop", id, options: { drain: true } })` stops a live async workflow in this session without killing running children: children that have not started are stopped, the script cannot start new children or `runs.host` commands, and children already running finish and keep their results. The workflow then ends as stopped and is never resumed. It cannot be combined with `childId`; a full `stop` still works during a drain.
|
|
395
399
|
- Inactive schedules can appear in the selector, but they are labeled as schedules and route through `schedule.pause`, not `stop`.
|
|
396
400
|
|
|
397
401
|
### steer
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "@vicary/pi-subagents",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.88.0",
|
|
5
5
|
"description": "Pi extension for single-agent delegation and scripted multi-agent workflows",
|
|
6
6
|
"author": "Nico Bailon",
|
|
7
7
|
"license": "MIT",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"@js-temporal/polyfill": "0.5.1",
|
|
21
21
|
"acorn": "8.18.0",
|
|
22
22
|
"jiti": "2.7.0",
|
|
23
|
-
"undici": "8.12.
|
|
23
|
+
"undici": "8.12.4",
|
|
24
24
|
"yaml": "2.8.3"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
@@ -135,5 +135,5 @@
|
|
|
135
135
|
"./prompts"
|
|
136
136
|
]
|
|
137
137
|
},
|
|
138
|
-
"gitHead": "
|
|
138
|
+
"gitHead": "dc58b0272437b63b167428647c94a09df31675fe"
|
|
139
139
|
}
|
|
@@ -68,9 +68,11 @@ return reviews.map((review) => review.output);
|
|
|
68
68
|
and plain helpers. Nested async functions, arrows, and methods are rejected.
|
|
69
69
|
- Every `runs.run` / `runs.all` item needs a stable `key`. Add a short
|
|
70
70
|
verb + behavior `label` unless the user gave one.
|
|
71
|
-
- Bind files with `output: "plans/x.md"`
|
|
72
|
-
|
|
73
|
-
|
|
71
|
+
- Bind files with `output: "plans/x.md"` and return `outputReference` or
|
|
72
|
+
`artifactPaths`; a filename in task text does not route output. Relative
|
|
73
|
+
paths land in run artifacts. Never send reports to the repo root. When the
|
|
74
|
+
task ends, delete scratch briefs, scripts and reports you wrote anywhere
|
|
75
|
+
else; keep final deliverables.
|
|
74
76
|
- `runs.lanes([{ key, stages: [...] }])` runs a predeclared plan: first stages
|
|
75
77
|
together, later stages in order per lane.
|
|
76
78
|
|
|
@@ -102,7 +104,13 @@ number.
|
|
|
102
104
|
`.pi/subagents/` does not). For Pi extension repos, put lane worktrees
|
|
103
105
|
outside `~/.pi/agent/extensions`, for example `~/.pi/agent/worktrees`.
|
|
104
106
|
- Reviewers use fresh context. Use `context: "fork"` only when the child needs
|
|
105
|
-
the parent's history; it requires a persisted parent session.
|
|
107
|
+
the parent's history; it requires a persisted parent session. Each fork
|
|
108
|
+
copies the parent's session file to
|
|
109
|
+
`<parent session file without .jsonl>/forks/<run id>/`:
|
|
110
|
+
before forking from a session file of hundreds of MB, run `df -h` on that
|
|
111
|
+
file's folder. Once a forked child is accepted or dropped and won't be
|
|
112
|
+
resumed, delete its `forks/<run id>/` folder; never one whose run is still
|
|
113
|
+
active.
|
|
106
114
|
- Children do not spawn subagents unless the parent delegated fanout and their
|
|
107
115
|
resolved `tools` include `subagent`.
|
|
108
116
|
- A failed workflow, launch, prompt runtime, extension load, or child tool
|
|
@@ -110,10 +118,11 @@ number.
|
|
|
110
118
|
verify a clean worktree or capture the partial diff, then retry the same way
|
|
111
119
|
once. Switching to `interactive_shell`, `pi -ne`, or another CLI needs owner
|
|
112
120
|
approval.
|
|
113
|
-
-
|
|
121
|
+
- Do not pass a hard `toolBudget` or tight `usageBudget` to mutation-capable workers. The default tool budget blocks read/search tools rather than mutation tools. If interrupted after a tool call starts, checkpoint after the current tool returns with changed files, build/test state, and commit or PR state.
|
|
114
122
|
- Route workers and scouts to a fast capable tier, serious reviews to a strong
|
|
115
123
|
tier, and top reasoning only to bounded read-only critique. Exact model names
|
|
116
|
-
belong in user or project settings, not here.
|
|
124
|
+
belong in user or project settings, not here. When neither the user nor
|
|
125
|
+
settings name a model, omit `model` so the child inherits the parent's.
|
|
117
126
|
- `subagent`, `subagents_enable`, `subagent_supervisor`, `contact_supervisor`, and `structured_output` are model-only: call them as ordinary model tool calls. Codemode scripts cannot reach them through `tools.*`, `ALL_TOOLS`, or `searchTools`.
|
|
118
127
|
- Receipts, CI, and review bots are evidence, not authority. Backlog, release,
|
|
119
128
|
and merge policy belong to the user's or project's own skill.
|
|
@@ -96,3 +96,4 @@ top-reasoning model is only a bounded read-only critic after ordinary evidence
|
|
|
96
96
|
falls short, never an autonomous root. Map tiers to real models in user or
|
|
97
97
|
project settings or a profile (guide `models/setting-defaults-and-overrides`,
|
|
98
98
|
`models/profiles-and-provider-model-catalogs`). Explicit user policy wins.
|
|
99
|
+
Never pick a model from memory.
|
|
@@ -17,6 +17,7 @@ interface ManagementParams {
|
|
|
17
17
|
agentScope?: unknown;
|
|
18
18
|
capabilities?: unknown;
|
|
19
19
|
config?: unknown;
|
|
20
|
+
search?: unknown;
|
|
20
21
|
}
|
|
21
22
|
export declare function editableAgentConfig(agent: AgentConfig): AgentConfig;
|
|
22
23
|
export declare function preservedAgentFrontmatterFields(agent: AgentConfig, cfg: Record<string, unknown>): Set<string>;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import * as fs from "node:fs";
|
|
2
2
|
import * as path from "node:path";
|
|
3
|
-
import { defaultInheritProjectContext, defaultInheritSkills, defaultSystemPromptMode, discoverAgentsAll, buildRuntimeName, findBlockingAgentDiagnostic, frontmatterNameForConfig, parsePackageName, mergeBuiltinAgentOverride, removeBuiltinAgentOverride, removeBuiltinAgentOverrideFields, resolveAgentName, } from "./agents.js";
|
|
3
|
+
import { defaultInheritProjectContext, defaultInheritSkills, defaultSystemPromptMode, discoverAgentsAll, buildRuntimeName, findBlockingAgentDiagnostic, frontmatterNameForConfig, MAX_LISTED_AGENTS, parsePackageName, mergeBuiltinAgentOverride, removeBuiltinAgentOverride, removeBuiltinAgentOverrideFields, resolveAgentName, } from "./agents.js";
|
|
4
4
|
import { serializeAgent } from "./agent-serializer.js";
|
|
5
5
|
import { mergeAgentsForScope } from "./agent-selection.js";
|
|
6
6
|
import { discoverAvailableSkills, resolveSkills } from "./skills.js";
|
|
7
7
|
import { buildProactiveSkillSubagentRecommendationLines, } from "./proactive-skills.js";
|
|
8
8
|
import { parseFrontmatter, parseUnquotedList } from "./frontmatter.js";
|
|
9
9
|
import { resolveEffectiveThinking, THINKING_LEVELS, toModelInfo } from "../shared/model-info.js";
|
|
10
|
-
import { isUnavailableSubagentModel, resolveSubagentModelOverride } from "../runs/shared/model-resolution.js";
|
|
10
|
+
import { isUnavailableSubagentModel, knownModelProviders, resolveSubagentModelOverride } from "../runs/shared/model-resolution.js";
|
|
11
11
|
import { validateToolBudgetConfig } from "../runs/shared/tool-budget.js";
|
|
12
12
|
import { formatReviewGateLabel, validateAcceptanceInput } from "../runs/shared/acceptance.js";
|
|
13
13
|
import { CODE_OWNED_EXTERNAL_CLI_ADAPTER_LABEL, isCodeOwnedExternalCliAdapterId, resolveExternalCliRunnerStatus, validateCodeOwnedProfileRunner } from "../runs/shared/external-cli-contract.js";
|
|
@@ -195,6 +195,8 @@ export function editableAgentConfig(agent) {
|
|
|
195
195
|
delete next.model;
|
|
196
196
|
if (!hasDeclaredField("thinking"))
|
|
197
197
|
delete next.thinking;
|
|
198
|
+
if (!hasDeclaredField("inheritGlobalContext"))
|
|
199
|
+
next.inheritGlobalContext = false;
|
|
198
200
|
return next;
|
|
199
201
|
};
|
|
200
202
|
const { override: _override, description: _description, output: _output, outputMode: _outputMode, defaultReads: _defaultReads, model: _model, fast: _fast, thinking: _thinking, systemPromptMode: _systemPromptMode, inheritProjectContext: _inheritProjectContext, inheritGlobalContext: _inheritGlobalContext, inheritSkills: _inheritSkills, defaultContext: _defaultContext, acceptanceRole: _acceptanceRole, disabled: _disabled, systemPrompt: _systemPrompt, skills: _skills, skillPath: _skillPath, tools: _tools, excludeTools: _excludeTools, mcpDirectTools: _mcpDirectTools, allowNestedSubagents: _allowNestedSubagents, allowedAgents: _allowedAgents, subagentOnlyExtensions: _subagentOnlyExtensions, mutationTools: _mutationTools, toolBudget: _toolBudget, ...editable } = withoutExtensions;
|
|
@@ -215,7 +217,7 @@ export function editableAgentConfig(agent) {
|
|
|
215
217
|
...(base.thinking !== undefined && hasDeclaredField("thinking") ? { thinking: base.thinking } : {}),
|
|
216
218
|
systemPromptMode: base.systemPromptMode,
|
|
217
219
|
inheritProjectContext: base.inheritProjectContext,
|
|
218
|
-
inheritGlobalContext: base.inheritGlobalContext,
|
|
220
|
+
inheritGlobalContext: hasDeclaredField("inheritGlobalContext") && base.inheritGlobalContext,
|
|
219
221
|
inheritSkills: base.inheritSkills,
|
|
220
222
|
...(base.defaultContext !== undefined ? { defaultContext: base.defaultContext } : {}),
|
|
221
223
|
...(base.acceptanceRole !== undefined ? { acceptanceRole: base.acceptanceRole } : {}),
|
|
@@ -1028,7 +1030,9 @@ export function handleList(params, ctx) {
|
|
|
1028
1030
|
scopedAgents = scopedAgents
|
|
1029
1031
|
.sort((a, b) => a.name.localeCompare(b.name));
|
|
1030
1032
|
const capabilityCeiling = resolveCurrentSubagentCapabilityCeiling(ctx.piSessionId);
|
|
1031
|
-
const
|
|
1033
|
+
const search = typeof params.search === "string" ? params.search.trim().toLowerCase() : "";
|
|
1034
|
+
const visibleAgents = scopedAgents.filter((a) => !a.disabled
|
|
1035
|
+
&& (!search || [a.name, a.description, ...(a.aliases ?? [])].some((text) => text.toLowerCase().includes(search))));
|
|
1032
1036
|
const agents = visibleAgents.filter((a) => isAgentAllowedByCapabilityCeiling(a.name, capabilityCeiling));
|
|
1033
1037
|
const restrictedAgents = visibleAgents.filter((a) => !isAgentAllowedByCapabilityCeiling(a.name, capabilityCeiling));
|
|
1034
1038
|
const restrictedSources = capabilityCeilingAgentRestrictionSources(capabilityCeiling);
|
|
@@ -1042,16 +1046,23 @@ export function handleList(params, ctx) {
|
|
|
1042
1046
|
const capabilityMode = params.capabilities === true;
|
|
1043
1047
|
const externalCliAvailability = capabilityMode ? externalCliAvailabilityForAgents([...agents, ...restrictedAgents]) : undefined;
|
|
1044
1048
|
const availableModels = capabilityMode ? ctx.modelRegistry.getAvailable().map(toModelInfo) : [];
|
|
1049
|
+
const knownProviders = knownModelProviders(ctx.modelRegistry);
|
|
1045
1050
|
const unavailableModels = new Set([...agents, ...restrictedAgents].filter((agent) => (agent.runner?.type ?? "pi") === "pi"
|
|
1046
|
-
&& isUnavailableSubagentModel(agent.model, availableModels, agent.modelProvider ?? ctx.model?.provider)));
|
|
1051
|
+
&& isUnavailableSubagentModel(agent.model, availableModels, agent.modelProvider ?? ctx.model?.provider, knownProviders)));
|
|
1047
1052
|
const formatLine = capabilityMode
|
|
1048
1053
|
? (agent, names) => formatAgentCapabilitiesLine(agent, names, externalCliAvailability, unavailableModels)
|
|
1049
1054
|
: formatAgentListLine;
|
|
1055
|
+
// A large catalog would otherwise put every agent's description into the model's context at once.
|
|
1056
|
+
const shownAgents = agents.slice(0, MAX_LISTED_AGENTS);
|
|
1057
|
+
const shownRestrictedAgents = restrictedAgents.slice(0, MAX_LISTED_AGENTS - shownAgents.length);
|
|
1058
|
+
const omittedCount = Math.max(0, agents.length + restrictedAgents.length - MAX_LISTED_AGENTS);
|
|
1050
1059
|
const lines = [
|
|
1051
1060
|
capabilityMode ? "Executable agents (capabilities):" : "Executable agents:",
|
|
1052
|
-
...formatAgentListSections(
|
|
1061
|
+
...formatAgentListSections(shownAgents, providerNameSet, formatLine),
|
|
1053
1062
|
];
|
|
1054
|
-
appendRestrictedAgentLines({ lines, agents:
|
|
1063
|
+
appendRestrictedAgentLines({ lines, agents: shownRestrictedAgents, sources: restrictedSources, providerNames: providerNameSet, formatLine });
|
|
1064
|
+
if (omittedCount > 0)
|
|
1065
|
+
lines.push("", `+${omittedCount} more; narrow with {action:"list", options:{search:"<term>"}}`);
|
|
1055
1066
|
appendExternalJobRegistryLine(lines, [...agents, ...restrictedAgents], providerStatus);
|
|
1056
1067
|
appendAgentDiagnosticLines(lines, d.agentDiagnostics);
|
|
1057
1068
|
if (proactiveSuggestions.length)
|
|
@@ -1094,6 +1105,7 @@ function handleModels(params, ctx) {
|
|
|
1094
1105
|
const effectiveAgents = effectiveAgentsForScope(scope, discovered, ctx.runtimeAgentOwner, ctx.model?.provider)
|
|
1095
1106
|
.sort((a, b) => a.name.localeCompare(b.name));
|
|
1096
1107
|
const availableModels = ctx.modelRegistry.getAvailable().map(toModelInfo);
|
|
1108
|
+
const knownProviders = knownModelProviders(ctx.modelRegistry);
|
|
1097
1109
|
const currentModel = ctx.model ? { provider: ctx.model.provider, id: ctx.model.id } : undefined;
|
|
1098
1110
|
const preferredProvider = ctx.model?.provider;
|
|
1099
1111
|
const capabilityCeiling = resolveCurrentSubagentCapabilityCeiling(ctx.piSessionId);
|
|
@@ -1127,9 +1139,9 @@ function handleModels(params, ctx) {
|
|
|
1127
1139
|
? [{ agent, name: requestedAgent }]
|
|
1128
1140
|
: [{ agent, name: agent.name }, ...(agent.aliases ?? []).map((name) => ({ agent, name }))]);
|
|
1129
1141
|
for (const { agent, name } of modelEntries) {
|
|
1130
|
-
const resolvedModel = resolveSubagentModelOverride(agent.model, currentModel, availableModels, agent.modelProvider ?? preferredProvider);
|
|
1142
|
+
const resolvedModel = resolveSubagentModelOverride(agent.model, currentModel, availableModels, agent.modelProvider ?? preferredProvider, { knownProviders });
|
|
1131
1143
|
const shownModel = resolvedModel === undefined ? "(unresolved)"
|
|
1132
|
-
: (agent.runner?.type ?? "pi") === "pi" && isUnavailableSubagentModel(agent.model, availableModels, agent.modelProvider ?? preferredProvider) ? `${resolvedModel} ${UNAVAILABLE_MODEL_MARKER}` : resolvedModel;
|
|
1144
|
+
: (agent.runner?.type ?? "pi") === "pi" && isUnavailableSubagentModel(agent.model, availableModels, agent.modelProvider ?? preferredProvider, knownProviders) ? `${resolvedModel} ${UNAVAILABLE_MODEL_MARKER}` : resolvedModel;
|
|
1133
1145
|
const effectiveThinking = resolveEffectiveThinking(resolvedModel, agent.thinking)
|
|
1134
1146
|
?? (agent.thinking === false ? "off" : undefined);
|
|
1135
1147
|
const source = `${formatModelSource(agent, currentModel)}${agent.disabled ? "; disabled" : ""}${isAgentAllowedByCapabilityCeiling(agent.name, capabilityCeiling) ? "" : "; restricted"}`;
|
|
@@ -1270,7 +1282,7 @@ export function handleCreate(params, ctx) {
|
|
|
1270
1282
|
const sw = skillsWarning(ctx.cwd, agent);
|
|
1271
1283
|
if (sw)
|
|
1272
1284
|
warnings.push(sw);
|
|
1273
|
-
fs.writeFileSync(targetPath, serializeAgent(agent), "utf-8");
|
|
1285
|
+
fs.writeFileSync(targetPath, serializeAgent(agent, { explicitInheritGlobalContext: hasKey(cfg, "inheritGlobalContext") }), "utf-8");
|
|
1274
1286
|
ctx.onAgentsChanged?.();
|
|
1275
1287
|
return result([`Created agent '${runtimeName}' at ${targetPath}.`, ...warnings].join("\n"));
|
|
1276
1288
|
}
|
|
@@ -2,6 +2,8 @@ import type { AgentConfig } from "./agents.ts";
|
|
|
2
2
|
export declare const KNOWN_FIELDS: Set<string>;
|
|
3
3
|
interface SerializeAgentOptions {
|
|
4
4
|
preserveFrontmatterFields?: ReadonlySet<string>;
|
|
5
|
+
/** The caller set inheritGlobalContext on create; write it even when false, because an absent field takes settings defaults. */
|
|
6
|
+
explicitInheritGlobalContext?: boolean;
|
|
5
7
|
}
|
|
6
8
|
export declare function serializeAgent(config: AgentConfig, options?: SerializeAgentOptions): string;
|
|
7
9
|
export {};
|
|
@@ -97,7 +97,7 @@ export function serializeAgent(config, options = {}) {
|
|
|
97
97
|
lines.push(`systemPromptMode: ${config.systemPromptMode}`);
|
|
98
98
|
if (!preservingExistingFrontmatter || preserve("inheritProjectContext"))
|
|
99
99
|
lines.push(`inheritProjectContext: ${config.inheritProjectContext ? "true" : "false"}`);
|
|
100
|
-
if (config.inheritGlobalContext || preserve("inheritGlobalContext"))
|
|
100
|
+
if (config.inheritGlobalContext || preserve("inheritGlobalContext") || options.explicitInheritGlobalContext)
|
|
101
101
|
lines.push(`inheritGlobalContext: ${config.inheritGlobalContext ? "true" : "false"}`);
|
|
102
102
|
if (!preservingExistingFrontmatter || preserve("inheritSkills"))
|
|
103
103
|
lines.push(`inheritSkills: ${config.inheritSkills ? "true" : "false"}`);
|
package/src/agents/agents.d.ts
CHANGED
|
@@ -235,6 +235,7 @@ export interface AgentDiscoveryResult {
|
|
|
235
235
|
}
|
|
236
236
|
/** Create formatter input from the exact discovery operation used for resolution. */
|
|
237
237
|
export declare function unknownAgentDiagnosticContext(discovered: Pick<AgentDiscoveryResult, "cwd" | "scope" | "directories" | "agents" | "disabledAgents">): UnknownAgentDiagnosticContext;
|
|
238
|
+
export declare const MAX_LISTED_AGENTS = 30;
|
|
238
239
|
/** One line per agent the caller can launch instead, so a wrong name needs no separate list call. */
|
|
239
240
|
export declare function formatAvailableAgentLines(agents: readonly AgentConfig[]): string[];
|
|
240
241
|
/** The closest agent name or alias when `name` looks like a typo of one. */
|