@xzzpig/pi-subagents 0.24.2 → 0.25.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +37 -0
- package/bundle/agent-management.js +4 -4
- package/bundle/agents.js +3 -3
- package/bundle/child-tool-plan.js +2 -2
- package/bundle/chunk-34TUUBRN.js +1107 -0
- package/bundle/{chunk-SW2VMNIU.js → chunk-5OD3OWTE.js} +2 -2
- package/bundle/{chunk-EUPJB4S7.js → chunk-5Z7JAORM.js} +196 -1219
- package/bundle/{chunk-LCDJWBVM.js → chunk-66JNFRFS.js} +1 -1
- package/bundle/{chunk-ED55MIC2.js → chunk-CGFF4WA3.js} +42 -19
- package/bundle/{chunk-TMHVDPYW.js → chunk-DLVPMML3.js} +263 -154
- package/bundle/{chunk-RU522D5W.js → chunk-FQPV4O6C.js} +183 -28
- package/bundle/chunk-HXRB42AF.js +108 -0
- package/bundle/{chunk-355ECEP2.js → chunk-IH7LQVEE.js} +29 -14
- package/bundle/{chunk-Z6TFJ6BR.js → chunk-INWSUNI6.js} +1 -1
- package/bundle/{chunk-CYY5UMJU.js → chunk-IXCEOEJT.js} +411 -249
- package/bundle/{chunk-WW76JRIX.js → chunk-JAXVBXGF.js} +1 -1
- package/bundle/{chunk-ICNYIALB.js → chunk-JH5H4CYJ.js} +784 -474
- package/bundle/{chunk-224WMDIV.js → chunk-JUYNN63E.js} +350 -123
- package/bundle/{chunk-35GII5EF.js → chunk-JWFLPSTP.js} +41 -117
- package/bundle/{chunk-XWWUDWUW.js → chunk-KRNBJPZ2.js} +670 -400
- package/bundle/{chunk-RB4GELQA.js → chunk-LPJEKHOY.js} +1 -1
- package/bundle/chunk-LYKG4FKH.js +523 -0
- package/bundle/{chunk-X6LOM3Z4.js → chunk-LZ3HBDTR.js} +161 -78
- package/bundle/{chunk-JEA2ZKUA.js → chunk-MMJQMPOK.js} +37 -165
- package/bundle/{chunk-FG6SQJAR.js → chunk-OGPOCGWX.js} +24 -6
- package/bundle/{chunk-FJWI64H7.js → chunk-RMSABUN3.js} +27 -13
- package/bundle/{chunk-H36HBZB2.js → chunk-SJPABBZG.js} +2 -2
- package/bundle/{chunk-4UH4WS4G.js → chunk-SNDCIJMK.js} +23 -12
- package/bundle/{chunk-O4D5PBVI.js → chunk-TM2K53NX.js} +3 -2
- package/bundle/{chunk-3U633XDZ.js → chunk-U3ZDUUTM.js} +11 -3
- package/bundle/{chunk-LVWU2HOO.js → chunk-ULGMXABL.js} +16 -7
- package/bundle/{chunk-WPW4V6HM.js → chunk-W7ZA6TYD.js} +2 -2
- package/bundle/{chunk-BQ2OAB4Q.js → chunk-WWDUNXSE.js} +67 -30
- package/bundle/{chunk-V2KFIGFH.js → chunk-XAC2XNAP.js} +503 -304
- 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 +27 -6
- package/docs/configuration.md +20 -8
- package/docs/extension-api.md +18 -1
- package/docs/models.md +6 -2
- package/docs/observability.md +2 -0
- package/docs/tool-reference.md +7 -1
- package/docs/workflows.md +30 -2
- package/package.json +2 -2
- 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 +46 -18
- package/src/agents/agent-memory.d.ts +1 -4
- package/src/agents/agent-memory.js +1 -4
- package/src/agents/agent-serializer.d.ts +2 -0
- package/src/agents/agent-serializer.js +1 -1
- package/src/agents/agents.d.ts +2 -3
- package/src/agents/agents.js +46 -20
- package/src/agents/frontmatter.js +1 -8
- package/src/agents/global-npm-root.d.ts +1 -0
- package/src/agents/global-npm-root.js +11 -3
- package/src/agents/skills.d.ts +0 -3
- package/src/agents/skills.js +0 -3
- package/src/api/preflight.d.ts +3 -1
- package/src/api/preflight.js +2 -0
- package/src/extension/config.d.ts +1 -0
- package/src/extension/config.js +13 -1
- package/src/extension/herdr-pi-bridge.js +10 -2
- package/src/extension/index.d.ts +0 -13
- package/src/extension/index.js +51 -37
- package/src/extension/public-execution.d.ts +1 -0
- package/src/extension/public-execution.js +4 -0
- package/src/extension/reply-workflow-script.js +24 -4
- package/src/extension/schemas.d.ts +12 -3
- package/src/extension/schemas.js +7 -3
- package/src/extension/session-switch.d.ts +25 -0
- package/src/extension/session-switch.js +138 -0
- package/src/extension/subagent-guide.d.ts +1 -1
- package/src/extension/subagent-guide.js +1 -1
- package/src/extension/subagent-launch-tool.d.ts +25 -0
- package/src/extension/subagent-launch-tool.js +48 -0
- package/src/extension/tool-activation.js +55 -15
- package/src/extension/tool-description.d.ts +1 -1
- package/src/extension/tool-description.js +14 -8
- package/src/inspectors/herdr/actions.d.ts +0 -1
- package/src/inspectors/herdr/actions.js +0 -1
- package/src/inspectors/session-roots-codec.d.ts +0 -1
- package/src/inspectors/session-roots-codec.js +0 -1
- package/src/inspectors/tmux/actions.d.ts +0 -1
- package/src/inspectors/tmux/actions.js +0 -1
- package/src/integrations/herdr-status.js +3 -8
- package/src/intercom/native-supervisor-channel.js +65 -9
- package/src/runs/background/async-execution.d.ts +7 -10
- package/src/runs/background/async-execution.js +66 -29
- package/src/runs/background/async-job-tracker.js +12 -0
- package/src/runs/background/async-resume.d.ts +2 -1
- package/src/runs/background/async-resume.js +114 -40
- package/src/runs/background/async-retention.d.ts +0 -2
- package/src/runs/background/async-retention.js +17 -6
- package/src/runs/background/async-status.d.ts +2 -0
- package/src/runs/background/async-status.js +4 -0
- package/src/runs/background/auto-drain.js +2 -1
- package/src/runs/background/boot-id.d.ts +1 -3
- package/src/runs/background/boot-id.js +1 -3
- package/src/runs/background/completion-batcher.d.ts +3 -4
- package/src/runs/background/completion-batcher.js +2 -3
- package/src/runs/background/control-channel.d.ts +0 -6
- package/src/runs/background/control-channel.js +0 -6
- package/src/runs/background/fleet-view.js +2 -3
- package/src/runs/background/notify.d.ts +0 -2
- package/src/runs/background/notify.js +0 -2
- package/src/runs/background/result-watcher.d.ts +1 -0
- package/src/runs/background/result-watcher.js +59 -29
- package/src/runs/background/resume-guidance.js +4 -2
- package/src/runs/background/retained-children.js +2 -1
- package/src/runs/background/run-child-session.d.ts +2 -3
- package/src/runs/background/run-child-session.js +5 -8
- package/src/runs/background/run-status.js +9 -7
- package/src/runs/background/runner-aliases.js +15 -0
- package/src/runs/background/scheduled-runs.d.ts +3 -1
- package/src/runs/background/scheduled-runs.js +13 -16
- 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 +2 -6
- package/src/runs/background/subagent-runner.js +88 -70
- package/src/runs/background/subagent-wait.js +12 -15
- package/src/runs/background/wait-config.d.ts +2 -0
- package/src/runs/background/wait-config.js +17 -3
- package/src/runs/background/wait-subscriptions.js +124 -12
- package/src/runs/background/wait-tool.js +4 -2
- package/src/runs/background/workflow-terminal-proof.d.ts +0 -1
- package/src/runs/background/workflow-terminal-proof.js +0 -1
- 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.d.ts +0 -3
- package/src/runs/foreground/execution.js +68 -84
- package/src/runs/foreground/fork-tool-result-handler.d.ts +60 -0
- package/src/runs/foreground/fork-tool-result-handler.js +83 -0
- package/src/runs/foreground/prompt-audit.js +1 -0
- package/src/runs/foreground/subagent-executor.d.ts +5 -10
- package/src/runs/foreground/subagent-executor.js +164 -49
- package/src/runs/shared/acceptance.js +69 -26
- 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-commands.js +15 -2
- package/src/runs/shared/child-hooks.d.ts +1 -7
- package/src/runs/shared/child-hooks.js +13 -5
- package/src/runs/shared/child-launch.js +6 -2
- package/src/runs/shared/child-runtime-config.d.ts +0 -1
- package/src/runs/shared/child-session.d.ts +6 -5
- package/src/runs/shared/child-session.js +85 -38
- package/src/runs/shared/child-tool-plan.d.ts +0 -1
- package/src/runs/shared/child-tool-plan.js +0 -1
- package/src/runs/shared/claude-code-adapter.js +11 -0
- package/src/runs/shared/external-cli-contract.d.ts +49 -0
- package/src/runs/shared/external-cli-contract.js +18 -13
- package/src/runs/shared/external-cli-runner.js +26 -6
- package/src/runs/shared/herdr-connection.js +2 -1
- package/src/runs/shared/herdr-pane-host.d.ts +2 -2
- package/src/runs/shared/herdr-pane-host.js +17 -1
- package/src/runs/shared/herdr-placed-run.js +51 -24
- package/src/runs/shared/lane-metadata.d.ts +0 -1
- package/src/runs/shared/lane-metadata.js +0 -1
- 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/mcp-direct-tool-grant.js +8 -1
- package/src/runs/shared/model-resolution-diagnostic.d.ts +0 -1
- package/src/runs/shared/model-resolution.d.ts +20 -5
- package/src/runs/shared/model-resolution.js +55 -50
- package/src/runs/shared/model-scope.d.ts +1 -5
- package/src/runs/shared/model-scope.js +1 -5
- package/src/runs/shared/mutation-evidence.d.ts +1 -1
- package/src/runs/shared/mutation-evidence.js +52 -7
- package/src/runs/shared/nested-events.d.ts +1 -0
- package/src/runs/shared/nested-events.js +1 -1
- package/src/runs/shared/parallel-utils.d.ts +0 -1
- package/src/runs/shared/permissions.js +5 -3
- package/src/runs/shared/placement-host.d.ts +5 -1
- package/src/runs/shared/rex-pane-host.d.ts +0 -1
- package/src/runs/shared/rex-pane-host.js +0 -2
- package/src/runs/shared/run-launch-folder.d.ts +12 -0
- package/src/runs/shared/run-launch-folder.js +21 -0
- package/src/runs/shared/runner-launcher.d.ts +12 -1
- package/src/runs/shared/runner-launcher.js +16 -0
- package/src/runs/shared/single-output.d.ts +3 -3
- package/src/runs/shared/single-output.js +5 -3
- package/src/runs/shared/structured-output.d.ts +8 -0
- package/src/runs/shared/structured-output.js +40 -5
- package/src/runs/shared/subagent-prompt-runtime.d.ts +0 -1
- package/src/runs/shared/subagent-prompt-runtime.js +18 -4
- package/src/runs/shared/supervisor-wait-timer.d.ts +16 -0
- package/src/runs/shared/supervisor-wait-timer.js +61 -0
- package/src/runs/shared/tool-timeout.js +2 -1
- package/src/runs/shared/worktree-cleanup-plan.d.ts +0 -1
- package/src/runs/shared/worktree-cleanup-plan.js +0 -1
- package/src/runs/shared/worktree.d.ts +3 -0
- package/src/runs/shared/worktree.js +20 -0
- package/src/shared/artifacts.d.ts +1 -0
- package/src/shared/artifacts.js +132 -22
- package/src/shared/capacity-resilient-json.d.ts +1 -1
- package/src/shared/child-cache-retention.d.ts +1 -2
- package/src/shared/child-cache-retention.js +1 -2
- package/src/shared/fleet-transcript-reader.d.ts +64 -0
- package/src/shared/fleet-transcript-reader.js +376 -0
- package/src/shared/formatters.d.ts +0 -18
- package/src/shared/formatters.js +0 -18
- 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/session-succession.d.ts +16 -1
- package/src/shared/session-succession.js +41 -2
- package/src/shared/session-warnings.d.ts +7 -0
- package/src/shared/session-warnings.js +26 -0
- package/src/shared/settings.d.ts +0 -23
- package/src/shared/settings.js +3 -35
- package/src/shared/status-format.d.ts +1 -0
- package/src/shared/status-format.js +1 -1
- package/src/shared/types.d.ts +108 -59
- package/src/shared/types.js +0 -12
- package/src/shared/utils.d.ts +3 -15
- package/src/shared/utils.js +4 -22
- package/src/shared/wait-tool-name.d.ts +8 -0
- package/src/shared/wait-tool-name.js +13 -0
- package/src/slash/slash-commands.js +2 -1
- package/src/slash/subagent-cost.d.ts +3 -2
- package/src/slash/subagent-cost.js +22 -3
- package/src/slash/subagents-admin.js +0 -1
- package/src/tui/fleet-native-transcript.js +1 -1
- package/src/tui/fleet-status.d.ts +0 -5
- package/src/tui/fleet-status.js +4 -24
- package/src/tui/fleet-transcript.d.ts +1 -57
- package/src/tui/fleet-transcript.js +4 -370
- package/src/tui/fleet.js +6 -4
- package/src/tui/render.d.ts +0 -9
- package/src/tui/render.js +194 -68
- package/src/tui/subagent-messages.js +3 -2
- package/src/watchdog/model-selection.js +2 -2
- package/src/watchdog/permission-arbiter.js +1 -0
- package/src/watchdog/register-child.d.ts +2 -3
- package/src/watchdog/register-child.js +2 -3
- package/src/watchdog/review.d.ts +0 -5
- package/src/watchdog/review.js +4 -3
- package/src/watchdog/turn-delta.js +2 -1
- package/src/workflows/scripted-workflow.d.ts +2 -0
- package/src/workflows/scripted-workflow.js +344 -59
- package/src/workflows/structured-workflow-scripts.d.ts +4 -3
- package/src/workflows/structured-workflow-scripts.js +32 -11
- package/src/workflows/workflow-launch-record.d.ts +15 -6
- package/src/workflows/workflow-launch-record.js +30 -12
- package/src/workflows/workflow-receipt.js +36 -53
- 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 +3 -3
- package/src/workflows/workflow-resume.d.ts +1 -1
- package/src/workflows/workflow-resume.js +13 -8
- package/src/workflows/workflow-script-worker.d.ts +13 -0
- package/src/workflows/workflow-script-worker.js +81 -0
- package/workflow-script-process.cjs +36 -0
- package/workflow-script-worker.cjs +4 -1
- package/bundle/chunk-U4ODUYAG.js +0 -235
|
@@ -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.
|
|
@@ -100,3 +100,4 @@ top-reasoning model is only a bounded read-only critic after ordinary evidence
|
|
|
100
100
|
falls short, never an autonomous root. Map tiers to real models in user or
|
|
101
101
|
project settings or a profile (guide `models/setting-defaults-and-overrides`,
|
|
102
102
|
`models/profiles-and-provider-model-catalogs`). Explicit user policy wins.
|
|
103
|
+
Never pick a model from memory.
|
|
@@ -20,6 +20,7 @@ interface ManagementParams {
|
|
|
20
20
|
agentScope?: unknown;
|
|
21
21
|
capabilities?: unknown;
|
|
22
22
|
config?: unknown;
|
|
23
|
+
search?: unknown;
|
|
23
24
|
}
|
|
24
25
|
export declare function sanitizeName(name: string): string;
|
|
25
26
|
export declare function availableAgentNamesForCwd(cwd: string): 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 { 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";
|
|
@@ -213,6 +213,8 @@ export function editableAgentConfig(agent) {
|
|
|
213
213
|
delete next.model;
|
|
214
214
|
if (!hasDeclaredField("thinking"))
|
|
215
215
|
delete next.thinking;
|
|
216
|
+
if (!hasDeclaredField("inheritGlobalContext"))
|
|
217
|
+
next.inheritGlobalContext = false;
|
|
216
218
|
return next;
|
|
217
219
|
};
|
|
218
220
|
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;
|
|
@@ -233,7 +235,7 @@ export function editableAgentConfig(agent) {
|
|
|
233
235
|
...(base.thinking !== undefined && hasDeclaredField("thinking") ? { thinking: base.thinking } : {}),
|
|
234
236
|
systemPromptMode: base.systemPromptMode,
|
|
235
237
|
inheritProjectContext: base.inheritProjectContext,
|
|
236
|
-
inheritGlobalContext: base.inheritGlobalContext,
|
|
238
|
+
inheritGlobalContext: hasDeclaredField("inheritGlobalContext") && base.inheritGlobalContext,
|
|
237
239
|
inheritSkills: base.inheritSkills,
|
|
238
240
|
...(base.defaultContext !== undefined ? { defaultContext: base.defaultContext } : {}),
|
|
239
241
|
...(base.acceptanceRole !== undefined ? { acceptanceRole: base.acceptanceRole } : {}),
|
|
@@ -809,7 +811,8 @@ function agentListMetadata(agent, providerNames, externalCliAvailability) {
|
|
|
809
811
|
function formatAgentListLine(agent, providerNames) {
|
|
810
812
|
return `- ${agent.name} (${agentListMetadata(agent, providerNames)}): ${agent.description}`;
|
|
811
813
|
}
|
|
812
|
-
|
|
814
|
+
const UNAVAILABLE_MODEL_MARKER = "(unavailable in the active model registry)";
|
|
815
|
+
function formatAgentCapabilitiesLine(agent, providerNames, externalCliAvailability, unavailableModels) {
|
|
813
816
|
const declaredTools = [
|
|
814
817
|
...(agent.tools ?? []),
|
|
815
818
|
...(agent.mcpDirectTools ?? []).map((tool) => `mcp:${tool}`),
|
|
@@ -828,6 +831,8 @@ function formatAgentCapabilitiesLine(agent, providerNames, externalCliAvailabili
|
|
|
828
831
|
model = agent.model;
|
|
829
832
|
if (agent.modelProvider && !agent.model.includes("/"))
|
|
830
833
|
model = `${agent.modelProvider}/${agent.model}`;
|
|
834
|
+
if (unavailableModels.has(agent))
|
|
835
|
+
model = `${model} ${UNAVAILABLE_MODEL_MARKER}`;
|
|
831
836
|
}
|
|
832
837
|
const thinking = agent.thinking === false ? "off" : agent.thinking ?? "default";
|
|
833
838
|
const machine = agent.machine ? `; Machine: ${agent.machine} (saved Herdr placement)` : "";
|
|
@@ -908,7 +913,7 @@ function agentCapabilityRow(agent, options) {
|
|
|
908
913
|
aliases: agent.aliases ? [...agent.aliases] : undefined,
|
|
909
914
|
runner: agentCapabilityRunner(agent, options.providerNames, options.externalCliAvailability),
|
|
910
915
|
tools: agentCapabilityTools(agent),
|
|
911
|
-
model: presentDetails({ value: agent.model, thinking: agent.thinking }),
|
|
916
|
+
model: presentDetails({ value: agent.model, thinking: agent.thinking, unavailable: options.unavailableModels.has(agent) || undefined }),
|
|
912
917
|
execution: presentDetails({ defaultAsync: agent.defaultAsync, timeoutMs: agent.defaultTimeoutMs }),
|
|
913
918
|
acceptance: presentDetails({ policy: agent.defaultAcceptance, role: agent.acceptanceRole }),
|
|
914
919
|
output: presentDetails({ path: agent.output, mode: agent.outputMode }),
|
|
@@ -918,8 +923,8 @@ function agentCapabilityRow(agent, options) {
|
|
|
918
923
|
function agentCapabilitiesSnapshot(input) {
|
|
919
924
|
return {
|
|
920
925
|
agents: [
|
|
921
|
-
...input.agents.map((agent) => agentCapabilityRow(agent, { executable: true, providerNames: input.providerNames, externalCliAvailability: input.externalCliAvailability })),
|
|
922
|
-
...input.restrictedAgents.map((agent) => agentCapabilityRow(agent, { executable: false, providerNames: input.providerNames, externalCliAvailability: input.externalCliAvailability, restrictionSources: input.restrictedSources })),
|
|
926
|
+
...input.agents.map((agent) => agentCapabilityRow(agent, { executable: true, providerNames: input.providerNames, externalCliAvailability: input.externalCliAvailability, unavailableModels: input.unavailableModels })),
|
|
927
|
+
...input.restrictedAgents.map((agent) => agentCapabilityRow(agent, { executable: false, providerNames: input.providerNames, externalCliAvailability: input.externalCliAvailability, unavailableModels: input.unavailableModels, restrictionSources: input.restrictedSources })),
|
|
923
928
|
],
|
|
924
929
|
restrictedCount: input.restrictedAgents.length,
|
|
925
930
|
...(input.restrictedSources?.length ? { capabilityCeilingSources: [...input.restrictedSources] } : {}),
|
|
@@ -952,6 +957,7 @@ function agentCapabilityDetails(input) {
|
|
|
952
957
|
restrictedAgents: input.restrictedAgents,
|
|
953
958
|
providerNames: input.providerNames,
|
|
954
959
|
externalCliAvailability: input.externalCliAvailability,
|
|
960
|
+
unavailableModels: input.unavailableModels,
|
|
955
961
|
restrictedSources: input.restrictedSources,
|
|
956
962
|
})),
|
|
957
963
|
};
|
|
@@ -1072,7 +1078,9 @@ export function handleList(params, ctx) {
|
|
|
1072
1078
|
scopedAgents = scopedAgents
|
|
1073
1079
|
.sort((a, b) => a.name.localeCompare(b.name));
|
|
1074
1080
|
const capabilityCeiling = resolveCurrentSubagentCapabilityCeiling(ctx.piSessionId);
|
|
1075
|
-
const
|
|
1081
|
+
const search = typeof params.search === "string" ? params.search.trim().toLowerCase() : "";
|
|
1082
|
+
const visibleAgents = scopedAgents.filter((a) => !a.disabled
|
|
1083
|
+
&& (!search || [a.name, a.description, ...(a.aliases ?? [])].some((text) => text.toLowerCase().includes(search))));
|
|
1076
1084
|
const agents = visibleAgents.filter((a) => isAgentAllowedByCapabilityCeiling(a.name, capabilityCeiling));
|
|
1077
1085
|
const restrictedAgents = visibleAgents.filter((a) => !isAgentAllowedByCapabilityCeiling(a.name, capabilityCeiling));
|
|
1078
1086
|
const restrictedSources = capabilityCeilingAgentRestrictionSources(capabilityCeiling);
|
|
@@ -1085,14 +1093,24 @@ export function handleList(params, ctx) {
|
|
|
1085
1093
|
const providerNameSet = providerNames(providerStatus);
|
|
1086
1094
|
const capabilityMode = params.capabilities === true;
|
|
1087
1095
|
const externalCliAvailability = capabilityMode ? externalCliAvailabilityForAgents([...agents, ...restrictedAgents]) : undefined;
|
|
1096
|
+
const availableModels = capabilityMode ? ctx.modelRegistry.getAvailable().map(toModelInfo) : [];
|
|
1097
|
+
const knownProviders = knownModelProviders(ctx.modelRegistry);
|
|
1098
|
+
const unavailableModels = new Set([...agents, ...restrictedAgents].filter((agent) => (agent.runner?.type ?? "pi") === "pi"
|
|
1099
|
+
&& isUnavailableSubagentModel(agent.model, availableModels, agent.modelProvider ?? ctx.model?.provider, knownProviders)));
|
|
1088
1100
|
const formatLine = capabilityMode
|
|
1089
|
-
? (agent, names) => formatAgentCapabilitiesLine(agent, names, externalCliAvailability)
|
|
1101
|
+
? (agent, names) => formatAgentCapabilitiesLine(agent, names, externalCliAvailability, unavailableModels)
|
|
1090
1102
|
: formatAgentListLine;
|
|
1103
|
+
// A large catalog would otherwise put every agent's description into the model's context at once.
|
|
1104
|
+
const shownAgents = agents.slice(0, MAX_LISTED_AGENTS);
|
|
1105
|
+
const shownRestrictedAgents = restrictedAgents.slice(0, MAX_LISTED_AGENTS - shownAgents.length);
|
|
1106
|
+
const omittedCount = Math.max(0, agents.length + restrictedAgents.length - MAX_LISTED_AGENTS);
|
|
1091
1107
|
const lines = [
|
|
1092
1108
|
capabilityMode ? "Executable agents (capabilities):" : "Executable agents:",
|
|
1093
|
-
...formatAgentListSections(
|
|
1109
|
+
...formatAgentListSections(shownAgents, providerNameSet, formatLine),
|
|
1094
1110
|
];
|
|
1095
|
-
appendRestrictedAgentLines({ lines, agents:
|
|
1111
|
+
appendRestrictedAgentLines({ lines, agents: shownRestrictedAgents, sources: restrictedSources, providerNames: providerNameSet, formatLine });
|
|
1112
|
+
if (omittedCount > 0)
|
|
1113
|
+
lines.push("", `+${omittedCount} more; narrow with {action:"list", options:{search:"<term>"}}`);
|
|
1096
1114
|
appendExternalJobRegistryLine(lines, [...agents, ...restrictedAgents], providerStatus);
|
|
1097
1115
|
appendAgentDiagnosticLines(lines, d.agentDiagnostics);
|
|
1098
1116
|
if (proactiveSuggestions.length)
|
|
@@ -1103,12 +1121,19 @@ export function handleList(params, ctx) {
|
|
|
1103
1121
|
restrictedAgents,
|
|
1104
1122
|
providerNames: providerNameSet,
|
|
1105
1123
|
externalCliAvailability: externalCliAvailability ?? new Map(),
|
|
1124
|
+
unavailableModels,
|
|
1106
1125
|
restrictedSources,
|
|
1107
1126
|
}));
|
|
1108
1127
|
}
|
|
1128
|
+
// User then project overrides are layered, so the override's top-level scope can name a file that did not set `model`.
|
|
1129
|
+
function modelOverrideFile(override) {
|
|
1130
|
+
const scopes = override.fieldScopes?.model;
|
|
1131
|
+
const scope = scopes?.includes("project") ? "project" : scopes?.includes("user") ? "user" : override.scope;
|
|
1132
|
+
return { scope, path: override.paths?.[scope] ?? override.path };
|
|
1133
|
+
}
|
|
1109
1134
|
function formatModelSource(agent, currentModel) {
|
|
1110
1135
|
if (agent.override && agent.model !== agent.override.base.model) {
|
|
1111
|
-
return `${agent.override.scope} override`;
|
|
1136
|
+
return `${modelOverrideFile(agent.override).scope} override`;
|
|
1112
1137
|
}
|
|
1113
1138
|
if (agent.modelSource?.type === "subagents.defaultModel" && agent.model === agent.modelSource.model) {
|
|
1114
1139
|
return `${agent.modelSource.scope} defaultModel`;
|
|
@@ -1128,6 +1153,7 @@ function handleModels(params, ctx) {
|
|
|
1128
1153
|
const effectiveAgents = effectiveAgentsForScope(scope, discovered, ctx.runtimeAgentOwner, ctx.model?.provider)
|
|
1129
1154
|
.sort((a, b) => a.name.localeCompare(b.name));
|
|
1130
1155
|
const availableModels = ctx.modelRegistry.getAvailable().map(toModelInfo);
|
|
1156
|
+
const knownProviders = knownModelProviders(ctx.modelRegistry);
|
|
1131
1157
|
const currentModel = ctx.model ? { provider: ctx.model.provider, id: ctx.model.id } : undefined;
|
|
1132
1158
|
const preferredProvider = ctx.model?.provider;
|
|
1133
1159
|
const capabilityCeiling = resolveCurrentSubagentCapabilityCeiling(ctx.piSessionId);
|
|
@@ -1161,19 +1187,21 @@ function handleModels(params, ctx) {
|
|
|
1161
1187
|
? [{ agent, name: requestedAgent }]
|
|
1162
1188
|
: [{ agent, name: agent.name }, ...(agent.aliases ?? []).map((name) => ({ agent, name }))]);
|
|
1163
1189
|
for (const { agent, name } of modelEntries) {
|
|
1164
|
-
const resolvedModel = resolveSubagentModelOverride(agent.model, currentModel, availableModels, agent.modelProvider ?? preferredProvider);
|
|
1190
|
+
const resolvedModel = resolveSubagentModelOverride(agent.model, currentModel, availableModels, agent.modelProvider ?? preferredProvider, { knownProviders });
|
|
1191
|
+
const shownModel = resolvedModel === undefined ? "(unresolved)"
|
|
1192
|
+
: (agent.runner?.type ?? "pi") === "pi" && isUnavailableSubagentModel(agent.model, availableModels, agent.modelProvider ?? preferredProvider, knownProviders) ? `${resolvedModel} ${UNAVAILABLE_MODEL_MARKER}` : resolvedModel;
|
|
1165
1193
|
const effectiveThinking = resolveEffectiveThinking(resolvedModel, agent.thinking)
|
|
1166
1194
|
?? (agent.thinking === false ? "off" : undefined);
|
|
1167
1195
|
const source = `${formatModelSource(agent, currentModel)}${agent.disabled ? "; disabled" : ""}${isAgentAllowedByCapabilityCeiling(agent.name, capabilityCeiling) ? "" : "; restricted"}`;
|
|
1168
1196
|
if (requestedAgent) {
|
|
1169
1197
|
lines.push(`Agent: ${requestedAgent}`);
|
|
1170
1198
|
lines.push("Effective model:");
|
|
1171
|
-
lines.push(` ${
|
|
1199
|
+
lines.push(` ${shownModel}`);
|
|
1172
1200
|
lines.push(`Source: ${source}`);
|
|
1173
1201
|
lines.push(`Thinking: ${effectiveThinking ?? "default"}`);
|
|
1174
1202
|
if (agent.override) {
|
|
1175
1203
|
lines.push("Override file:");
|
|
1176
|
-
lines.push(` ${agent.override.path}`);
|
|
1204
|
+
lines.push(` ${modelOverrideFile(agent.override).path}`);
|
|
1177
1205
|
}
|
|
1178
1206
|
if (agent.model && resolvedModel && agent.model !== resolvedModel) {
|
|
1179
1207
|
lines.push("Requested model setting:");
|
|
@@ -1189,12 +1217,12 @@ function handleModels(params, ctx) {
|
|
|
1189
1217
|
}
|
|
1190
1218
|
lines.push(name);
|
|
1191
1219
|
lines.push(" model:");
|
|
1192
|
-
lines.push(` ${
|
|
1220
|
+
lines.push(` ${shownModel}`);
|
|
1193
1221
|
lines.push(` source: ${source}`);
|
|
1194
1222
|
lines.push(` thinking: ${effectiveThinking ?? "default"}`);
|
|
1195
1223
|
if (agent.override) {
|
|
1196
1224
|
lines.push(" override file:");
|
|
1197
|
-
lines.push(` ${agent.override.path}`);
|
|
1225
|
+
lines.push(` ${modelOverrideFile(agent.override).path}`);
|
|
1198
1226
|
}
|
|
1199
1227
|
if (agent.model && resolvedModel && agent.model !== resolvedModel) {
|
|
1200
1228
|
lines.push(" requested model setting:");
|
|
@@ -1302,7 +1330,7 @@ export function handleCreate(params, ctx) {
|
|
|
1302
1330
|
const sw = skillsWarning(ctx.cwd, agent);
|
|
1303
1331
|
if (sw)
|
|
1304
1332
|
warnings.push(sw);
|
|
1305
|
-
fs.writeFileSync(targetPath, serializeAgent(agent), "utf-8");
|
|
1333
|
+
fs.writeFileSync(targetPath, serializeAgent(agent, { explicitInheritGlobalContext: hasKey(cfg, "inheritGlobalContext") }), "utf-8");
|
|
1306
1334
|
ctx.onAgentsChanged?.();
|
|
1307
1335
|
return result([`Created agent '${runtimeName}' at ${targetPath}.`, ...warnings].join("\n"));
|
|
1308
1336
|
}
|
|
@@ -15,13 +15,10 @@ import { type AgentConfig, type AgentMemoryConfig } from "./agents.ts";
|
|
|
15
15
|
export declare const AGENT_MEMORY_DIR_NAME = "agent-memory";
|
|
16
16
|
export declare const AGENT_MEMORY_FILE = "MEMORY.md";
|
|
17
17
|
export declare const MAX_MEMORY_LINES = 200;
|
|
18
|
-
/** Parse a `memory` frontmatter block string into a typed config, or undefined if invalid. */
|
|
19
18
|
export declare function parseMemoryFrontmatter(raw: string | undefined): AgentMemoryConfig | undefined;
|
|
20
|
-
/**
|
|
19
|
+
/** Inherits default builtins when `tools` is unset. */
|
|
21
20
|
export declare function agentHasWriteTools(agent: Pick<AgentConfig, "tools">): boolean;
|
|
22
21
|
/**
|
|
23
|
-
* Resolve a memory directory under `rootDir` for the given scoped path.
|
|
24
|
-
*
|
|
25
22
|
* Rejects empty paths, `.`/`..` segments, paths that escape the root, and
|
|
26
23
|
* existing directories whose real path (via symlink) lands outside the root.
|
|
27
24
|
*/
|
|
@@ -29,7 +29,6 @@ function unquoteFrontmatterValue(value) {
|
|
|
29
29
|
}
|
|
30
30
|
return trimmed;
|
|
31
31
|
}
|
|
32
|
-
/** Parse a `memory` frontmatter block string into a typed config, or undefined if invalid. */
|
|
33
32
|
export function parseMemoryFrontmatter(raw) {
|
|
34
33
|
if (!raw)
|
|
35
34
|
return undefined;
|
|
@@ -60,7 +59,7 @@ export function parseMemoryFrontmatter(raw) {
|
|
|
60
59
|
return undefined;
|
|
61
60
|
return { scope, path: scopedPath };
|
|
62
61
|
}
|
|
63
|
-
/**
|
|
62
|
+
/** Inherits default builtins when `tools` is unset. */
|
|
64
63
|
export function agentHasWriteTools(agent) {
|
|
65
64
|
const tools = agent.tools;
|
|
66
65
|
if (!tools)
|
|
@@ -168,8 +167,6 @@ function resolveProjectMemoryRoot(projectRoot) {
|
|
|
168
167
|
}
|
|
169
168
|
}
|
|
170
169
|
/**
|
|
171
|
-
* Resolve a memory directory under `rootDir` for the given scoped path.
|
|
172
|
-
*
|
|
173
170
|
* Rejects empty paths, `.`/`..` segments, paths that escape the root, and
|
|
174
171
|
* existing directories whose real path (via symlink) lands outside the root.
|
|
175
172
|
*/
|
|
@@ -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 {};
|
|
@@ -100,7 +100,7 @@ export function serializeAgent(config, options = {}) {
|
|
|
100
100
|
lines.push(`systemPromptMode: ${config.systemPromptMode}`);
|
|
101
101
|
if (!preservingExistingFrontmatter || preserve("inheritProjectContext"))
|
|
102
102
|
lines.push(`inheritProjectContext: ${config.inheritProjectContext ? "true" : "false"}`);
|
|
103
|
-
if (config.inheritGlobalContext || preserve("inheritGlobalContext"))
|
|
103
|
+
if (config.inheritGlobalContext || preserve("inheritGlobalContext") || options.explicitInheritGlobalContext)
|
|
104
104
|
lines.push(`inheritGlobalContext: ${config.inheritGlobalContext ? "true" : "false"}`);
|
|
105
105
|
if (!preservingExistingFrontmatter || preserve("inheritSkills"))
|
|
106
106
|
lines.push(`inheritSkills: ${config.inheritSkills ? "true" : "false"}`);
|
package/src/agents/agents.d.ts
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Agent discovery and configuration
|
|
3
|
-
*/
|
|
4
1
|
import * as fs from "node:fs";
|
|
5
2
|
import { type AcceptanceInput, type AcceptanceRole, type AgentRunnerConfig, type JsonSchemaObject, type OutputMode, type ToolBudgetConfig } from "../shared/types.ts";
|
|
6
3
|
import { type ModelScopeConfig } from "../runs/shared/model-scope.ts";
|
|
@@ -89,6 +86,7 @@ interface BuiltinAgentOverrideInfo {
|
|
|
89
86
|
base: BuiltinAgentOverrideBase;
|
|
90
87
|
fields?: string[];
|
|
91
88
|
fieldScopes?: Record<string, Array<"user" | "project">>;
|
|
89
|
+
paths?: Partial<Record<"user" | "project", string>>;
|
|
92
90
|
}
|
|
93
91
|
export interface AgentModelSourceInfo {
|
|
94
92
|
type: "subagents.defaultModel";
|
|
@@ -245,6 +243,7 @@ export interface AgentDiscoveryResult {
|
|
|
245
243
|
}
|
|
246
244
|
/** Create formatter input from the exact discovery operation used for resolution. */
|
|
247
245
|
export declare function unknownAgentDiagnosticContext(discovered: Pick<AgentDiscoveryResult, "cwd" | "scope" | "directories" | "agents" | "disabledAgents">): UnknownAgentDiagnosticContext;
|
|
246
|
+
export declare const MAX_LISTED_AGENTS = 30;
|
|
248
247
|
/** One line per agent the caller can launch instead, so a wrong name needs no separate list call. */
|
|
249
248
|
export declare function formatAvailableAgentLines(agents: readonly AgentConfig[]): string[];
|
|
250
249
|
/** The closest agent name or alias when `name` looks like a typo of one. */
|
package/src/agents/agents.js
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Agent discovery and configuration
|
|
3
|
-
*/
|
|
4
1
|
import { execSync } from "node:child_process";
|
|
5
2
|
import * as fs from "node:fs";
|
|
6
3
|
import { parse as parseYaml } from "yaml";
|
|
@@ -89,7 +86,7 @@ export function unknownAgentDiagnosticContext(discovered) {
|
|
|
89
86
|
...(discovered.disabledAgents?.length ? { disabledAgents: discovered.disabledAgents } : {}),
|
|
90
87
|
};
|
|
91
88
|
}
|
|
92
|
-
const MAX_LISTED_AGENTS = 30;
|
|
89
|
+
export const MAX_LISTED_AGENTS = 30;
|
|
93
90
|
const MAX_LISTED_DESCRIPTION_CHARS = 80;
|
|
94
91
|
/** One line per agent the caller can launch instead, so a wrong name needs no separate list call. */
|
|
95
92
|
export function formatAvailableAgentLines(agents) {
|
|
@@ -100,7 +97,7 @@ export function formatAvailableAgentLines(agents) {
|
|
|
100
97
|
return `- ${agent.name} (${agent.source})${short ? ` — ${short}` : ""}`;
|
|
101
98
|
});
|
|
102
99
|
if (sorted.length > MAX_LISTED_AGENTS)
|
|
103
|
-
lines.push(`+${sorted.length - MAX_LISTED_AGENTS} more; {action:"list"}`);
|
|
100
|
+
lines.push(`+${sorted.length - MAX_LISTED_AGENTS} more; {action:"list", options:{search:"<term>"}}`);
|
|
104
101
|
return lines.length ? lines : ["- (none)"];
|
|
105
102
|
}
|
|
106
103
|
/** The closest agent name or alias when `name` looks like a typo of one. */
|
|
@@ -972,21 +969,24 @@ function readSubagentSettings(filePath) {
|
|
|
972
969
|
const subagentsObject = subagents;
|
|
973
970
|
let disableBuiltins;
|
|
974
971
|
if ("disableBuiltins" in subagentsObject) {
|
|
975
|
-
if (typeof subagentsObject.disableBuiltins === "boolean")
|
|
972
|
+
if (typeof subagentsObject.disableBuiltins === "boolean")
|
|
976
973
|
disableBuiltins = subagentsObject.disableBuiltins;
|
|
977
|
-
|
|
978
|
-
else {
|
|
974
|
+
else
|
|
979
975
|
throw new Error(`Subagent settings in '${filePath}' have invalid 'disableBuiltins'; expected a boolean.`);
|
|
980
|
-
}
|
|
981
976
|
}
|
|
982
977
|
let disableThinking;
|
|
983
978
|
if ("disableThinking" in subagentsObject) {
|
|
984
|
-
if (typeof subagentsObject.disableThinking === "boolean")
|
|
979
|
+
if (typeof subagentsObject.disableThinking === "boolean")
|
|
985
980
|
disableThinking = subagentsObject.disableThinking;
|
|
986
|
-
|
|
987
|
-
else {
|
|
981
|
+
else
|
|
988
982
|
throw new Error(`Subagent settings in '${filePath}' have invalid 'disableThinking'; expected a boolean.`);
|
|
989
|
-
|
|
983
|
+
}
|
|
984
|
+
let defaultInheritGlobalContext;
|
|
985
|
+
if ("defaultInheritGlobalContext" in subagentsObject) {
|
|
986
|
+
if (typeof subagentsObject.defaultInheritGlobalContext === "boolean")
|
|
987
|
+
defaultInheritGlobalContext = subagentsObject.defaultInheritGlobalContext;
|
|
988
|
+
else
|
|
989
|
+
throw new Error(`Subagent settings in '${filePath}' have invalid 'defaultInheritGlobalContext'; expected a boolean.`);
|
|
990
990
|
}
|
|
991
991
|
let defaultModel;
|
|
992
992
|
if ("defaultModel" in subagentsObject) {
|
|
@@ -1078,6 +1078,7 @@ function readSubagentSettings(filePath) {
|
|
|
1078
1078
|
...(maxThinking !== undefined ? { maxThinking } : {}),
|
|
1079
1079
|
...(defaultExtensions !== undefined ? { defaultExtensions } : {}),
|
|
1080
1080
|
...(defaultSubagentOnlyExtensions !== undefined ? { defaultSubagentOnlyExtensions } : {}),
|
|
1081
|
+
...(defaultInheritGlobalContext !== undefined ? { defaultInheritGlobalContext } : {}),
|
|
1081
1082
|
...(agentScanDirs !== undefined ? { agentScanDirs } : {}),
|
|
1082
1083
|
...(agentExcludeDirs !== undefined ? { agentExcludeDirs } : {}),
|
|
1083
1084
|
...(disableBuiltins !== undefined ? { disableBuiltins } : {}),
|
|
@@ -1217,8 +1218,27 @@ function applySubagentDefaultSubagentOnlyExtensions(agents, defaultSubagentOnlyE
|
|
|
1217
1218
|
return next;
|
|
1218
1219
|
});
|
|
1219
1220
|
}
|
|
1220
|
-
function
|
|
1221
|
-
|
|
1221
|
+
function resolveSubagentDefaultInheritGlobalContext(userSettings, projectSettings, projectSettingsPath) {
|
|
1222
|
+
if (projectSettingsPath && projectSettings.defaultInheritGlobalContext !== undefined)
|
|
1223
|
+
return projectSettings.defaultInheritGlobalContext;
|
|
1224
|
+
return userSettings.defaultInheritGlobalContext;
|
|
1225
|
+
}
|
|
1226
|
+
// The parsed field is a plain boolean, so only the frontmatter key tells an explicit `false` from an unset field.
|
|
1227
|
+
function applySubagentDefaultInheritGlobalContext(agents, defaultInheritGlobalContext) {
|
|
1228
|
+
if (!defaultInheritGlobalContext)
|
|
1229
|
+
return agents;
|
|
1230
|
+
return agents.map((agent) => {
|
|
1231
|
+
const frontmatterFields = agentFrontmatterFields.get(agent);
|
|
1232
|
+
if (agent.inheritGlobalContext || frontmatterFields?.has("inheritGlobalContext"))
|
|
1233
|
+
return agent;
|
|
1234
|
+
const next = { ...agent, inheritGlobalContext: true };
|
|
1235
|
+
if (frontmatterFields)
|
|
1236
|
+
agentFrontmatterFields.set(next, frontmatterFields);
|
|
1237
|
+
return next;
|
|
1238
|
+
});
|
|
1239
|
+
}
|
|
1240
|
+
function applySubagentDefaults(agents, defaultModel, defaultProvider, defaultThinking, defaultExtensions, defaultSubagentOnlyExtensions, defaultInheritGlobalContext) {
|
|
1241
|
+
return applySubagentDefaultInheritGlobalContext(applySubagentDefaultSubagentOnlyExtensions(applySubagentDefaultExtensions(applySubagentDefaultThinking(applySubagentDefaultModel(agents, defaultModel, defaultProvider), defaultThinking), defaultExtensions), defaultSubagentOnlyExtensions), defaultInheritGlobalContext);
|
|
1222
1242
|
}
|
|
1223
1243
|
function applyToolsOverride(target, toolsOverride) {
|
|
1224
1244
|
if (toolsOverride === "inherit") {
|
|
@@ -1242,6 +1262,7 @@ function applyBuiltinOverride(agent, override, meta) {
|
|
|
1242
1262
|
base: agent.override?.base ?? cloneOverrideBase(agent),
|
|
1243
1263
|
fields: [...new Set([...(agent.override?.fields ?? []), ...Object.keys(override)])].sort(),
|
|
1244
1264
|
fieldScopes: Object.fromEntries(Object.entries({ ...(agent.override?.fieldScopes ?? {}) }).map(([field, scopes]) => [field, [...scopes]])),
|
|
1265
|
+
paths: { ...agent.override?.paths, [meta.scope]: meta.path },
|
|
1245
1266
|
};
|
|
1246
1267
|
for (const field of Object.keys(override)) {
|
|
1247
1268
|
const scopes = overrideInfo.fieldScopes[field] ?? [];
|
|
@@ -1393,13 +1414,16 @@ function applyBuiltinOverrides(builtinAgents, userSettings, projectSettings, use
|
|
|
1393
1414
|
};
|
|
1394
1415
|
return builtinAgents.map((agent) => {
|
|
1395
1416
|
const projectOverride = projectSettings.overrides[agent.name];
|
|
1417
|
+
const userOverride = userSettings.overrides[agent.name];
|
|
1396
1418
|
if (projectOverride && projectSettingsPath) {
|
|
1397
|
-
|
|
1419
|
+
const withUserOverride = userOverride
|
|
1420
|
+
? applyBuiltinOverride(agent, userOverride, { scope: "user", path: userSettingsPath })
|
|
1421
|
+
: agent;
|
|
1422
|
+
return applyGlobalThinking(applyBuiltinOverride(withUserOverride, projectOverride, { scope: "project", path: projectSettingsPath }), projectOverride.thinking !== undefined || (!projectThinkingConfigured && userOverride?.thinking !== undefined));
|
|
1398
1423
|
}
|
|
1399
1424
|
if (projectBulkDisabled && projectSettingsPath) {
|
|
1400
1425
|
return applyGlobalThinking(applyBuiltinOverride(agent, { disabled: true }, { scope: "project", path: projectSettingsPath }), false);
|
|
1401
1426
|
}
|
|
1402
|
-
const userOverride = userSettings.overrides[agent.name];
|
|
1403
1427
|
if (userOverride) {
|
|
1404
1428
|
return applyGlobalThinking(applyBuiltinOverride(agent, userOverride, { scope: "user", path: userSettingsPath }), !projectThinkingConfigured && userOverride.thinking !== undefined);
|
|
1405
1429
|
}
|
|
@@ -2542,7 +2566,7 @@ function getAgentDiscoverySources(cwd, preferredModelProvider, includeChains = f
|
|
|
2542
2566
|
const key = discoveryCacheKey(cwd, preferredModelProvider, globalNpmRoot, projectTrusted);
|
|
2543
2567
|
const cached = agentDiscoveryCache.get(key);
|
|
2544
2568
|
if (cached && cached.fingerprint === discoveryFingerprint(cached.sources)) {
|
|
2545
|
-
if (includeChains) {
|
|
2569
|
+
if (includeChains && !cached.sources.userChains) {
|
|
2546
2570
|
ensureDiscoveryChains(cached.sources);
|
|
2547
2571
|
cached.fingerprint = discoveryFingerprint(cached.sources);
|
|
2548
2572
|
}
|
|
@@ -2591,7 +2615,8 @@ function configuredAgentsForScope(sources, scope, settingsScope = scope) {
|
|
|
2591
2615
|
const maxThinking = resolveSubagentMaxThinking(userSettings, projectSettings, sources.projectSettingsPath);
|
|
2592
2616
|
const defaultExtensions = resolveSubagentDefaultExtensions(userSettings, projectSettings, sources.projectSettingsPath);
|
|
2593
2617
|
const defaultSubagentOnlyExtensions = resolveSubagentDefaultSubagentOnlyExtensions(userSettings, projectSettings, sources.projectSettingsPath);
|
|
2594
|
-
const
|
|
2618
|
+
const defaultInheritGlobalContext = resolveSubagentDefaultInheritGlobalContext(userSettings, projectSettings, sources.projectSettingsPath);
|
|
2619
|
+
const applyDefaults = (agents) => applySubagentDefaults(agents, defaultModel, defaultProvider, defaultThinking, defaultExtensions, defaultSubagentOnlyExtensions, defaultInheritGlobalContext);
|
|
2595
2620
|
const builtin = applyBuiltinOverrides(applyDefaults(sources.builtinLoaded.agents), userSettings, projectSettings, sources.userSettingsPath, sources.projectSettingsPath);
|
|
2596
2621
|
const user = applyCustomAgentOverrides(applyDefaults(scope === "project" ? [] : sources.userLoaded.flatMap((loaded) => loaded.loaded.agents)), userSettings, projectSettings, sources.userSettingsPath, sources.projectSettingsPath);
|
|
2597
2622
|
const projectMap = new Map();
|
|
@@ -2757,6 +2782,7 @@ function discoverAgentsUncached(cwd, scope, preferredModelProvider, options = {}
|
|
|
2757
2782
|
const maxThinking = resolveSubagentMaxThinking(userSettings, projectSettings, projectSettingsPath);
|
|
2758
2783
|
const defaultExtensions = resolveSubagentDefaultExtensions(userSettings, projectSettings, projectSettingsPath);
|
|
2759
2784
|
const defaultSubagentOnlyExtensions = resolveSubagentDefaultSubagentOnlyExtensions(userSettings, projectSettings, projectSettingsPath);
|
|
2785
|
+
const defaultInheritGlobalContext = resolveSubagentDefaultInheritGlobalContext(userSettings, projectSettings, projectSettingsPath);
|
|
2760
2786
|
const modelScope = projectSettings.modelScope ?? userSettings.modelScope;
|
|
2761
2787
|
const injectAgents = projectSettings.injectAgents !== undefined
|
|
2762
2788
|
? projectSettings.injectAgents
|
|
@@ -2765,7 +2791,7 @@ function discoverAgentsUncached(cwd, scope, preferredModelProvider, options = {}
|
|
|
2765
2791
|
const isExcluded = agentExclusions(agentExclusionRoots(userSettingsPath, projectSettingsPath));
|
|
2766
2792
|
const directories = [reportAgentDefinitionDirectory("builtin", BUILTIN_AGENTS_DIR, BUILTIN_AGENT_DEFINITION_INSPECTION)];
|
|
2767
2793
|
const builtinLoaded = loadAgentsFromDefinitionFiles(BUILTIN_AGENT_DEFINITION_FILES, "builtin");
|
|
2768
|
-
const applyDefaults = (agents) => applySubagentDefaults(agents, defaultModel, defaultProvider, defaultThinking, defaultExtensions, defaultSubagentOnlyExtensions);
|
|
2794
|
+
const applyDefaults = (agents) => applySubagentDefaults(agents, defaultModel, defaultProvider, defaultThinking, defaultExtensions, defaultSubagentOnlyExtensions, defaultInheritGlobalContext);
|
|
2769
2795
|
const builtinAgents = applyBuiltinOverrides(applyDefaults(builtinLoaded.agents), userSettings, projectSettings, userSettingsPath, projectSettingsPath);
|
|
2770
2796
|
const userScanDirs = settingsAgentScanDirs(userSettings.agentScanDirs ?? [], isExcluded);
|
|
2771
2797
|
const projectScanDirs = settingsAgentScanDirs(projectSettings.agentScanDirs ?? [], isExcluded);
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Escape regex special characters for use in a RegExp constructor.
|
|
3
|
-
*/
|
|
4
1
|
function escapeRegex(s) {
|
|
5
2
|
return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
6
3
|
}
|
|
@@ -91,7 +88,7 @@ export function parseFrontmatter(content) {
|
|
|
91
88
|
let currentFolded = false;
|
|
92
89
|
let currentLiteral = false;
|
|
93
90
|
for (const line of lines) {
|
|
94
|
-
const indent = line.search(/\S|$/);
|
|
91
|
+
const indent = line.search(/\S|$/);
|
|
95
92
|
const trimmed = line.trim();
|
|
96
93
|
// Comment lines are content only inside a | or > block scalar. Elsewhere they must
|
|
97
94
|
// neither end a pending list block nor become part of its value.
|
|
@@ -99,11 +96,9 @@ export function parseFrontmatter(content) {
|
|
|
99
96
|
continue;
|
|
100
97
|
// Exactly-empty lines belong to any pending block, not only to | and > scalars.
|
|
101
98
|
if (currentKey !== null && currentBlockLines !== null && (indent > (currentIndent ?? 0) || trimmed === "")) {
|
|
102
|
-
// This line is part of the current block value
|
|
103
99
|
currentBlockLines.push(line);
|
|
104
100
|
continue;
|
|
105
101
|
}
|
|
106
|
-
// Flush any pending block value
|
|
107
102
|
if (currentKey !== null && currentBlockLines !== null) {
|
|
108
103
|
frontmatter[currentKey] = flushBlockLines(currentBlockLines, currentFolded, currentLiteral);
|
|
109
104
|
currentKey = null;
|
|
@@ -135,12 +130,10 @@ export function parseFrontmatter(content) {
|
|
|
135
130
|
currentLiteral = isLiteral;
|
|
136
131
|
}
|
|
137
132
|
else {
|
|
138
|
-
// Simple key: value
|
|
139
133
|
frontmatter[key] = value;
|
|
140
134
|
}
|
|
141
135
|
}
|
|
142
136
|
}
|
|
143
|
-
// Flush final block value
|
|
144
137
|
if (currentKey !== null && currentBlockLines !== null) {
|
|
145
138
|
frontmatter[currentKey] = flushBlockLines(currentBlockLines, currentFolded, currentLiteral);
|
|
146
139
|
}
|
|
@@ -3,6 +3,9 @@ import { promises as fs } from "node:fs";
|
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
/** Optional global package discovery; a failure never prevents local discovery. */
|
|
5
5
|
export async function resolveGlobalNpmRoot(options = {}) {
|
|
6
|
+
const signal = options.signal;
|
|
7
|
+
if (signal?.aborted)
|
|
8
|
+
return null;
|
|
6
9
|
const env = options.env ?? process.env;
|
|
7
10
|
const offline = env.PI_OFFLINE?.toLowerCase();
|
|
8
11
|
if (offline === "1" || offline === "true" || offline === "yes")
|
|
@@ -17,6 +20,8 @@ export async function resolveGlobalNpmRoot(options = {}) {
|
|
|
17
20
|
// Invalid APPDATA roots fall back to npm (including disappearing directories).
|
|
18
21
|
}
|
|
19
22
|
}
|
|
23
|
+
if (signal?.aborted)
|
|
24
|
+
return null;
|
|
20
25
|
const timeoutMs = options.timeoutMs ?? 5000;
|
|
21
26
|
const output = await new Promise((resolve) => {
|
|
22
27
|
let settled = false;
|
|
@@ -25,6 +30,7 @@ export async function resolveGlobalNpmRoot(options = {}) {
|
|
|
25
30
|
return;
|
|
26
31
|
settled = true;
|
|
27
32
|
clearTimeout(timer);
|
|
33
|
+
signal?.removeEventListener("abort", cancel);
|
|
28
34
|
resolve(value);
|
|
29
35
|
};
|
|
30
36
|
const commandOptions = {
|
|
@@ -40,11 +46,13 @@ export async function resolveGlobalNpmRoot(options = {}) {
|
|
|
40
46
|
const child = (options.platform ?? process.platform) === "win32"
|
|
41
47
|
? exec("npm root -g", commandOptions, callback)
|
|
42
48
|
: execFile("npm", ["root", "-g"], commandOptions, callback);
|
|
43
|
-
|
|
44
|
-
const timer = setTimeout(() => {
|
|
49
|
+
const cancel = () => {
|
|
45
50
|
child.kill();
|
|
46
51
|
finish(null);
|
|
47
|
-
}
|
|
52
|
+
};
|
|
53
|
+
// Resolve at the deadline even if inherited pipes hold the callback open.
|
|
54
|
+
const timer = setTimeout(cancel, timeoutMs);
|
|
55
|
+
signal?.addEventListener("abort", cancel, { once: true });
|
|
48
56
|
});
|
|
49
57
|
if (!output)
|
|
50
58
|
return null;
|
package/src/agents/skills.d.ts
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Skill resolution and caching for subagent extension
|
|
3
|
-
*/
|
|
4
1
|
export type SkillSource = "project" | "user" | "project-package" | "user-package" | "project-settings" | "user-settings" | "extension" | "builtin" | "unknown";
|
|
5
2
|
interface ResolvedSkill {
|
|
6
3
|
name: string;
|
package/src/agents/skills.js
CHANGED
package/src/api/preflight.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type AgentConfig, type AgentScope, type AgentSource } from "../agents/agents.ts";
|
|
2
|
-
import { type AvailableModelInfo, type ParentModel } from "../runs/shared/model-resolution.ts";
|
|
2
|
+
import { type AvailableModelInfo, type KnownProviders, type ParentModel } from "../runs/shared/model-resolution.ts";
|
|
3
3
|
import { type ThinkingLevel } from "../shared/thinking-ceiling.ts";
|
|
4
4
|
import { type ArtifactDirPreference, type ArtifactPaths, type IntercomBridgeConfig, type IntercomBridgeMode, type JsonSchemaObject, type OutputMode } from "../shared/types.ts";
|
|
5
5
|
import { type ResolvedSubagentCapabilityCeiling, type SubagentCapabilityAudit } from "../runs/shared/capability-ceiling.ts";
|
|
@@ -36,6 +36,8 @@ export interface SubagentLaunchContractInput {
|
|
|
36
36
|
fullId?: string;
|
|
37
37
|
reasoning?: boolean;
|
|
38
38
|
}>;
|
|
39
|
+
/** Every provider in Pi's full catalog (`ctx.modelRegistry.getAll()`), signed in or not, so a `provider/id` never resolves under another provider. */
|
|
40
|
+
knownProviders?: KnownProviders;
|
|
39
41
|
preferredProvider?: string;
|
|
40
42
|
skill?: string | string[] | boolean;
|
|
41
43
|
output?: string | boolean;
|