@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
|
@@ -2,7 +2,7 @@ import { randomUUID } from "node:crypto";
|
|
|
2
2
|
import * as fs from "node:fs";
|
|
3
3
|
import * as path from "node:path";
|
|
4
4
|
import { discoverAgents, findBlockingAgentDiagnostic, formatAvailableAgentLines, formatUnknownAgentError, resolveAgentName, suggestAgentName, unknownAgentDiagnosticContext } from "../../agents/agents.js";
|
|
5
|
-
import { getArtifactsDir, getProjectArtifactPackagingWarning, getProjectSubagentsDir } from "../../shared/artifacts.js";
|
|
5
|
+
import { getArtifactsDir, getProjectArtifactPackagingWarning, getProjectSubagentsDir, missingForkCopyNote } from "../../shared/artifacts.js";
|
|
6
6
|
import { writeAtomicJson } from "../../shared/atomic-json.js";
|
|
7
7
|
import { createCapacityResilientJsonWriter } from "../../shared/capacity-resilient-json.js";
|
|
8
8
|
import { reportSessionWarning } from "../../shared/session-warnings.js";
|
|
@@ -24,7 +24,7 @@ import { commandAction } from "./command-action.js";
|
|
|
24
24
|
import { handleWatchdogToolAction, WATCHDOG_TOOL_ACTIONS } from "../../watchdog/tool-actions.js";
|
|
25
25
|
import { applyWatchdogLaunchRules } from "../../watchdog/rules.js";
|
|
26
26
|
import { childWatchdogProgressForModel } from "../../watchdog/child-status.js";
|
|
27
|
-
import { normalizeParentModel, resolveEffectiveSubagentModel, resolveModelOrigin, scopedModelIdsFromContext } from "../shared/model-resolution.js";
|
|
27
|
+
import { knownModelProviders, normalizeParentModel, resolveEffectiveSubagentModel, resolveModelOrigin, scopedModelIdsFromContext } from "../shared/model-resolution.js";
|
|
28
28
|
import { projectChainOutputSchemas, resolveEffectiveOutputSchema } from "../shared/child-launch-plan.js";
|
|
29
29
|
import { formatRetainedChildren, listRetainedChildren } from "../background/retained-children.js";
|
|
30
30
|
import { resolveModelScopesForAgent } from "../shared/model-scope.js";
|
|
@@ -44,6 +44,7 @@ import { createPrunedForkSessionWriter } from "../../shared/pruned-fork.js";
|
|
|
44
44
|
import { resolveCurrentSessionId } from "../../shared/session-identity.js";
|
|
45
45
|
import { currentCompletionOwnerId } from "../../shared/completion-owner.js";
|
|
46
46
|
import { SUBAGENT_ASYNC_COMPLETE_EVENT } from "../../shared/types.js";
|
|
47
|
+
import { resolveConfigDefaultTimeoutMs } from "../../extension/config.js";
|
|
47
48
|
import { applyIntercomBridgeToAgent, INTERCOM_BRIDGE_MARKER, resolveIntercomBridge, resolveIntercomSessionTarget, resolveSubagentIntercomTarget } from "../../intercom/intercom-bridge.js";
|
|
48
49
|
import { formatControlIntercomMessage, formatControlNoticeMessage, resolveControlConfig, shouldNotifyControlEvent } from "../shared/subagent-control.js";
|
|
49
50
|
import { formatSpawnBudget, getSpawnBudgetSnapshot, grantSpawnBudget, preflightSpawnBudget, preflightSpawnBudgetGrant, reserveSpawnBudget } from "../shared/spawn-budget.js";
|
|
@@ -702,7 +703,7 @@ function resolveForegroundResumeTarget(params, state, options = {}) {
|
|
|
702
703
|
throw new Error(`Foreground run '${run.runId}' child ${index} session file must be a .jsonl file: ${child.sessionFile}`);
|
|
703
704
|
const sessionFile = path.resolve(child.sessionFile);
|
|
704
705
|
if (!fs.existsSync(sessionFile))
|
|
705
|
-
throw new Error(`Foreground run '${run.runId}' child ${index} session file does not exist: ${child.sessionFile}`);
|
|
706
|
+
throw new Error(`Foreground run '${run.runId}' child ${index} session file does not exist: ${child.sessionFile}${missingForkCopyNote(sessionFile)}`);
|
|
706
707
|
return {
|
|
707
708
|
runId: run.runId,
|
|
708
709
|
mode: run.mode,
|
|
@@ -1063,6 +1064,7 @@ function appendStepToAsyncChain(input) {
|
|
|
1063
1064
|
parentProviderRegistry: input.ctx.modelRegistry,
|
|
1064
1065
|
currentModel: parentModel,
|
|
1065
1066
|
scopedModelIds: scopedModelIdsFromContext(input.ctx),
|
|
1067
|
+
knownProviders: knownModelProviders(input.ctx.modelRegistry),
|
|
1066
1068
|
modelScope: discoveredForAppend.modelScope,
|
|
1067
1069
|
modelResponseAliases: input.deps.config.modelResponseAliases,
|
|
1068
1070
|
interactive: input.ctx.hasUI,
|
|
@@ -1189,7 +1191,7 @@ function validateNestedSessionFile(run, trustedSessionRoots, resolveSource, visi
|
|
|
1189
1191
|
if (!path.isAbsolute(sessionFile))
|
|
1190
1192
|
throw new Error(`Nested run '${run.id}' session file must be absolute: ${sessionFile}`);
|
|
1191
1193
|
if (!fs.existsSync(resolved))
|
|
1192
|
-
throw new Error(`Nested run '${run.id}' session file does not exist: ${sessionFile}`);
|
|
1194
|
+
throw new Error(`Nested run '${run.id}' session file does not exist: ${sessionFile}${missingForkCopyNote(resolved)}`);
|
|
1193
1195
|
const stat = fs.lstatSync(resolved);
|
|
1194
1196
|
if (!stat.isFile() || stat.isSymbolicLink())
|
|
1195
1197
|
throw new Error(`Nested run '${run.id}' session file is not a regular file: ${sessionFile}`);
|
|
@@ -1551,6 +1553,7 @@ async function resumeExternalJobFollowUp(input) {
|
|
|
1551
1553
|
parentProviderRegistry: input.ctx.modelRegistry,
|
|
1552
1554
|
currentModel: parentModel,
|
|
1553
1555
|
scopedModelIds: scopedModelIdsFromContext(input.ctx),
|
|
1556
|
+
knownProviders: knownModelProviders(input.ctx.modelRegistry),
|
|
1554
1557
|
modelScope: input.modelScope,
|
|
1555
1558
|
modelResponseAliases: input.deps.config.modelResponseAliases,
|
|
1556
1559
|
interactive: input.ctx.hasUI,
|
|
@@ -1855,6 +1858,7 @@ async function resumeAsyncRun(input) {
|
|
|
1855
1858
|
parentProviderRegistry: input.ctx.modelRegistry,
|
|
1856
1859
|
currentModel: parentModel,
|
|
1857
1860
|
scopedModelIds: scopedModelIdsFromContext(input.ctx),
|
|
1861
|
+
knownProviders: knownModelProviders(input.ctx.modelRegistry),
|
|
1858
1862
|
modelScope,
|
|
1859
1863
|
modelResponseAliases: input.deps.config.modelResponseAliases,
|
|
1860
1864
|
runnerLaunchers: input.deps.config.runnerLaunchers,
|
|
@@ -1998,6 +2002,7 @@ async function resumeAsyncRun(input) {
|
|
|
1998
2002
|
parentProviderRegistry: input.ctx.modelRegistry,
|
|
1999
2003
|
currentModel: parentModel,
|
|
2000
2004
|
scopedModelIds: scopedModelIdsFromContext(input.ctx),
|
|
2005
|
+
knownProviders: knownModelProviders(input.ctx.modelRegistry),
|
|
2001
2006
|
modelScope,
|
|
2002
2007
|
// Absence in the retained contract is meaningful; never acquire current aliases.
|
|
2003
2008
|
modelResponseAliases: recoveryDescriptor ? recoveryDescriptor.modelResponseAliases : foregroundContract?.modelResponseAliases,
|
|
@@ -2698,18 +2703,6 @@ function timerDelayOverflowError(name, value) {
|
|
|
2698
2703
|
? `${name} must be a positive integer no larger than ${MAX_TIMER_DELAY_MS}.`
|
|
2699
2704
|
: undefined;
|
|
2700
2705
|
}
|
|
2701
|
-
/**
|
|
2702
|
-
* Resolve the optional global default runtime deadline from extension config
|
|
2703
|
-
* (`config.timeoutMs`). Returns undefined for unset or invalid values so callers
|
|
2704
|
-
* use no configured deadline. "Invalid" covers non-positive-integer
|
|
2705
|
-
* values and values above `MAX_TIMER_DELAY_MS`; the latter would overflow the
|
|
2706
|
-
* Node.js timer and expire the run almost immediately instead of running long.
|
|
2707
|
-
*/
|
|
2708
|
-
export function resolveConfigDefaultTimeoutMs(raw) {
|
|
2709
|
-
if (typeof raw !== "number" || !Number.isInteger(raw) || raw <= 0 || raw > MAX_TIMER_DELAY_MS)
|
|
2710
|
-
return undefined;
|
|
2711
|
-
return raw;
|
|
2712
|
-
}
|
|
2713
2706
|
export function resolveForegroundTimeout(params, defaultTimeoutMs) {
|
|
2714
2707
|
const rawTimeout = params.timeoutMs;
|
|
2715
2708
|
const rawMaxRuntime = params.maxRuntimeMs;
|
|
@@ -2862,7 +2855,7 @@ function resolveStaticLaunchSummary(input) {
|
|
|
2862
2855
|
const modelScopes = resolveModelScopesForAgent(input.modelScope, input.agent, input.parentModel, input.scopedModelIds);
|
|
2863
2856
|
const model = externalRunner
|
|
2864
2857
|
? undefined
|
|
2865
|
-
: resolveEffectiveSubagentModel(input.explicitModel, agentConfig?.model, input.parentModel, input.availableModels, agentConfig?.modelProvider ?? input.currentProvider,
|
|
2858
|
+
: resolveEffectiveSubagentModel(input.explicitModel, agentConfig?.model, input.parentModel, input.availableModels, agentConfig?.modelProvider ?? input.currentProvider, { scope: modelScopes, knownProviders: input.knownProviders });
|
|
2866
2859
|
const thinkingOverride = externalRunner ? undefined : input.thinkingOverrideForTask();
|
|
2867
2860
|
const thinking = externalRunner ? undefined : resolveEffectiveThinking(model, thinkingOverride ?? agentConfig?.thinking);
|
|
2868
2861
|
return {
|
|
@@ -2880,6 +2873,7 @@ function collectStaticLaunchSummaries(input) {
|
|
|
2880
2873
|
parentModel: input.parentModel,
|
|
2881
2874
|
scopedModelIds: input.scopedModelIds,
|
|
2882
2875
|
availableModels: input.availableModels,
|
|
2876
|
+
knownProviders: input.knownProviders,
|
|
2883
2877
|
currentProvider: input.currentProvider,
|
|
2884
2878
|
modelScope: input.modelScope,
|
|
2885
2879
|
thinkingOverrideForTask: input.thinkingOverrideForTask,
|
|
@@ -3159,6 +3153,7 @@ async function runAsyncPath(data, deps) {
|
|
|
3159
3153
|
parentProviderRegistry: ctx.modelRegistry,
|
|
3160
3154
|
currentModel: parentModel,
|
|
3161
3155
|
scopedModelIds: data.scopedModelIds,
|
|
3156
|
+
knownProviders: knownModelProviders(ctx.modelRegistry),
|
|
3162
3157
|
modelScope: data.modelScope,
|
|
3163
3158
|
modelResponseAliases: deps.config.modelResponseAliases,
|
|
3164
3159
|
runnerLaunchers: deps.config.runnerLaunchers,
|
|
@@ -3203,8 +3198,9 @@ async function runAsyncPath(data, deps) {
|
|
|
3203
3198
|
const modelOverride = a.runner?.type === "external-cli" || a.runner?.type === "external-job"
|
|
3204
3199
|
? params.model ?? (externalRunnerWithoutExplicitModel ? undefined : a.model)
|
|
3205
3200
|
: resolveEffectiveSubagentModel(params.model, a.model, parentModel, availableModels, a.modelProvider ?? currentProvider, {
|
|
3206
|
-
|
|
3201
|
+
scope: modelScopes,
|
|
3207
3202
|
source: modelOrigin === "explicit" ? "explicit" : "inherited",
|
|
3203
|
+
knownProviders: asyncCtx.knownProviders,
|
|
3208
3204
|
});
|
|
3209
3205
|
const modelOverrideFromParent = modelOrigin === "inherited";
|
|
3210
3206
|
const launchRuleError = applyWatchdogLaunchRules({ cwd: effectiveCwd, agent: a.name, model: modelOverride ?? (parentModel && `${parentModel.provider}/${parentModel.id}`), warn: (violation) => deps.watchdog?.displayRuleWarning(violation) });
|
|
@@ -3632,6 +3628,7 @@ async function runSinglePath(data, deps) {
|
|
|
3632
3628
|
const parentModel = data.parentModel;
|
|
3633
3629
|
const currentProvider = parentModel?.provider;
|
|
3634
3630
|
const availableModels = ctx.modelRegistry.getAvailable().map(toModelInfo);
|
|
3631
|
+
const knownProviders = knownModelProviders(ctx.modelRegistry);
|
|
3635
3632
|
const modelScopes = resolveModelScopesForAgent(data.modelScope, agentConfig.name, parentModel, data.scopedModelIds);
|
|
3636
3633
|
let task = typeof params.task === "string" ? params.task : "";
|
|
3637
3634
|
const modelOrigin = resolveModelOrigin({
|
|
@@ -3641,8 +3638,9 @@ async function runSinglePath(data, deps) {
|
|
|
3641
3638
|
parentModel,
|
|
3642
3639
|
});
|
|
3643
3640
|
let modelOverride = resolveEffectiveSubagentModel(params.model, agentConfig.model, parentModel, availableModels, agentConfig.modelProvider ?? currentProvider, {
|
|
3644
|
-
|
|
3641
|
+
scope: modelScopes,
|
|
3645
3642
|
source: modelOrigin === "explicit" ? "explicit" : "inherited",
|
|
3643
|
+
knownProviders,
|
|
3646
3644
|
});
|
|
3647
3645
|
const modelOverrideFromParent = modelOrigin === "inherited";
|
|
3648
3646
|
const launchRuleError = applyWatchdogLaunchRules({ cwd: effectiveCwd, agent: agentConfig.name, model: modelOverride ?? (parentModel && `${parentModel.provider}/${parentModel.id}`), warn: (violation) => deps.watchdog?.displayRuleWarning(violation) });
|
|
@@ -3890,6 +3888,7 @@ async function runSinglePath(data, deps) {
|
|
|
3890
3888
|
thinkingCeiling: agentConfig.maxThinking,
|
|
3891
3889
|
extensionBindings: params.extensionBindings,
|
|
3892
3890
|
availableModels,
|
|
3891
|
+
knownProviders,
|
|
3893
3892
|
modelResponseAliases,
|
|
3894
3893
|
preferredModelProvider: currentProvider,
|
|
3895
3894
|
modelScope: modelScopes,
|
|
@@ -5167,6 +5166,7 @@ export function createSubagentExecutor(deps) {
|
|
|
5167
5166
|
const controller = new AbortController();
|
|
5168
5167
|
deps.state.workflowControllers ??= new Map();
|
|
5169
5168
|
deps.state.workflowChildStops ??= new Map();
|
|
5169
|
+
deps.state.workflowDrains ??= new Map();
|
|
5170
5170
|
deps.state.workflowControllers.set(workflowRunId, controller);
|
|
5171
5171
|
workflowCapacity?.markWorkflowStarted();
|
|
5172
5172
|
if (workflowCapacity)
|
|
@@ -5797,6 +5797,36 @@ export function createSubagentExecutor(deps) {
|
|
|
5797
5797
|
else
|
|
5798
5798
|
deps.state.workflowChildStops?.delete(workflowRunId);
|
|
5799
5799
|
},
|
|
5800
|
+
registerDrain: (drain) => {
|
|
5801
|
+
if (!drain)
|
|
5802
|
+
deps.state.workflowDrains?.delete(workflowRunId);
|
|
5803
|
+
else
|
|
5804
|
+
deps.state.workflowDrains?.set(workflowRunId, () => {
|
|
5805
|
+
if (workflowRunEvidence.drainRequestedAt === undefined) {
|
|
5806
|
+
// The marker must be on disk before anything is stopped: without it a reload during the drain would resume the run.
|
|
5807
|
+
const previousWorkflow = status.workflow;
|
|
5808
|
+
workflowRunEvidence.drainRequestedAt = Date.now();
|
|
5809
|
+
status.workflow = { ...(previousWorkflow ?? { trace: [], emits: [], console: [] }), drainRequestedAt: workflowRunEvidence.drainRequestedAt };
|
|
5810
|
+
let saved = false;
|
|
5811
|
+
try {
|
|
5812
|
+
persist();
|
|
5813
|
+
saved = runPersistence.pendingCount() === 0;
|
|
5814
|
+
}
|
|
5815
|
+
catch (error) {
|
|
5816
|
+
console.error(`Failed to save the drain request for async workflow '${workflowRunId}':`, error);
|
|
5817
|
+
}
|
|
5818
|
+
if (!saved) {
|
|
5819
|
+
delete workflowRunEvidence.drainRequestedAt;
|
|
5820
|
+
status.workflow = previousWorkflow;
|
|
5821
|
+
// Replaces a queued write that still carries the marker.
|
|
5822
|
+
persist({ tolerateStatusWriteFailure: true });
|
|
5823
|
+
return { ok: false };
|
|
5824
|
+
}
|
|
5825
|
+
}
|
|
5826
|
+
// Deferred so a full stop that stops the last running child aborts with its own reason first.
|
|
5827
|
+
return { ok: true, started: drain(() => queueMicrotask(() => controller.abort(new Error("Workflow drained: started children finished; no new children were started.")))) };
|
|
5828
|
+
});
|
|
5829
|
+
},
|
|
5800
5830
|
...(workflowState ? { state: workflowState } : {}),
|
|
5801
5831
|
onTrace: updateTrace,
|
|
5802
5832
|
onChildSettled: (notification) => {
|
|
@@ -5960,6 +5990,8 @@ export function createSubagentExecutor(deps) {
|
|
|
5960
5990
|
step.currentToolArgs = progress.currentToolArgs;
|
|
5961
5991
|
step.currentToolStartedAt = progress.currentToolStartedAt;
|
|
5962
5992
|
step.currentPath = progress.currentPath;
|
|
5993
|
+
step.progressText = progress.progressText;
|
|
5994
|
+
step.progressUpdatedAt = progress.progressUpdatedAt;
|
|
5963
5995
|
step.recentTools = progress.recentTools.map((tool) => ({ ...tool }));
|
|
5964
5996
|
step.recentOutput = [...progress.recentOutput];
|
|
5965
5997
|
step.turnCount = progress.turnCount;
|
|
@@ -6139,8 +6171,7 @@ export function createSubagentExecutor(deps) {
|
|
|
6139
6171
|
const workflowOutput = typeof workflowChildDefaults.output === "string" || typeof workflowChildDefaults.output === "boolean" ? workflowChildDefaults.output : undefined;
|
|
6140
6172
|
const configuredOutputBaseDir = resolveConfiguredSingleRunOutputBaseDir(deps);
|
|
6141
6173
|
const workflowAggregateOutputPath = resolveSingleOutputPath(workflowOutput, ctx.cwd, workflowCwd, resolveSingleRunOutputBaseDir(deps, workflowArtifactsDir, foregroundWorkflowRunId));
|
|
6142
|
-
//
|
|
6143
|
-
// within artifact retention, which only removes top-level files.
|
|
6174
|
+
// Outside outputs/ so it cannot overwrite a child's report.
|
|
6144
6175
|
const workflowFullResultPath = path.join(workflowArtifactsDir, `${sanitizeRunPathSegment(foregroundWorkflowRunId)}_workflow-result.md`);
|
|
6145
6176
|
const claimedOutputPaths = new Map();
|
|
6146
6177
|
const childOutputOverrides = new Map();
|
|
@@ -7027,6 +7058,8 @@ export function createSubagentExecutor(deps) {
|
|
|
7027
7058
|
}
|
|
7028
7059
|
if (action === "stop") {
|
|
7029
7060
|
const targetRunId = paramsWithResolvedCwd.runId ?? paramsWithResolvedCwd.id;
|
|
7061
|
+
if (paramsWithResolvedCwd.drain && paramsWithResolvedCwd.childId !== undefined)
|
|
7062
|
+
return { content: [{ type: "text", text: "action='stop' drain applies to a whole workflow; omit childId." }], isError: true, details: { mode: "management", results: [] } };
|
|
7030
7063
|
// Whole-workflow stops reach stopAsyncRun below, which stops a live workflow in-process.
|
|
7031
7064
|
const workflowRunId = targetRunId && paramsWithResolvedCwd.childId !== undefined ? resolveLiveWorkflowRunId(deps, targetRunId) : undefined;
|
|
7032
7065
|
if (workflowRunId && paramsWithResolvedCwd.childId !== undefined) {
|
|
@@ -7073,7 +7106,7 @@ export function createSubagentExecutor(deps) {
|
|
|
7073
7106
|
if (paramsWithResolvedCwd.dir) {
|
|
7074
7107
|
try {
|
|
7075
7108
|
const location = resolveAsyncRunLocation(paramsWithResolvedCwd, DIRS.async, DIRS.results);
|
|
7076
|
-
const stopResult = stopAsyncRun(deps.state, location.resolvedId ?? targetRunId ?? path.basename(location.asyncDir ?? paramsWithResolvedCwd.dir), deps.kill, location, paramsWithResolvedCwd.childId);
|
|
7109
|
+
const stopResult = stopAsyncRun(deps.state, location.resolvedId ?? targetRunId ?? path.basename(location.asyncDir ?? paramsWithResolvedCwd.dir), deps.kill, location, paramsWithResolvedCwd.childId, paramsWithResolvedCwd.drain);
|
|
7077
7110
|
return stopResult ?? { content: [{ type: "text", text: `No running or queued async run was found for '${targetRunId ?? paramsWithResolvedCwd.dir}'.` }], isError: true, details: { mode: "management", results: [] } };
|
|
7078
7111
|
}
|
|
7079
7112
|
catch (error) {
|
|
@@ -7094,7 +7127,7 @@ export function createSubagentExecutor(deps) {
|
|
|
7094
7127
|
return { content: [{ type: "text", text: "action='stop' supports current-session top-level async runs only." }], isError: true, details: { mode: "management", results: [] } };
|
|
7095
7128
|
if (resolved?.kind === "foreground")
|
|
7096
7129
|
return { content: [{ type: "text", text: "action='stop' supports async runs only. Use action='interrupt' for foreground runs." }], isError: true, details: { mode: "management", results: [] } };
|
|
7097
|
-
const stopResult = stopAsyncRun(deps.state, resolved?.kind === "async" ? resolved.id : targetRunId, deps.kill, resolved?.kind === "async" ? resolved.location : undefined, paramsWithResolvedCwd.childId);
|
|
7130
|
+
const stopResult = stopAsyncRun(deps.state, resolved?.kind === "async" ? resolved.id : targetRunId, deps.kill, resolved?.kind === "async" ? resolved.location : undefined, paramsWithResolvedCwd.childId, paramsWithResolvedCwd.drain);
|
|
7098
7131
|
if (stopResult)
|
|
7099
7132
|
return stopResult;
|
|
7100
7133
|
return {
|
|
@@ -7643,6 +7676,7 @@ export function createSubagentExecutor(deps) {
|
|
|
7643
7676
|
parentModel: requestParentModel,
|
|
7644
7677
|
scopedModelIds: scopedModelIdsFromContext(ctx),
|
|
7645
7678
|
availableModels: ctx.modelRegistry.getAvailable().map(toModelInfo),
|
|
7679
|
+
knownProviders: knownModelProviders(ctx.modelRegistry),
|
|
7646
7680
|
currentProvider: requestParentModel?.provider,
|
|
7647
7681
|
modelScope,
|
|
7648
7682
|
thinkingOverrideForTask,
|
|
@@ -33,6 +33,8 @@ export interface AsyncStatusSnapshotNode {
|
|
|
33
33
|
updatedAt?: number;
|
|
34
34
|
endedAt?: number;
|
|
35
35
|
activity?: AsyncStatusSnapshotActivity;
|
|
36
|
+
progressText?: string;
|
|
37
|
+
progressUpdatedAt?: number;
|
|
36
38
|
/** Step nodes only: the agent the child runs as, and the model and thinking level it reports. */
|
|
37
39
|
agent?: string;
|
|
38
40
|
model?: string;
|
|
@@ -137,6 +137,8 @@ function projectStep(step, index, depth, ctx) {
|
|
|
137
137
|
const activity = activityFor(step, ctx);
|
|
138
138
|
const { id, label } = stepIdentity(step, index, ctx);
|
|
139
139
|
const agent = publicOptionalText(step.agent, ctx.caps.maxStringLength);
|
|
140
|
+
const progressText = publicOptionalText(step.progressText, ctx.caps.maxStringLength);
|
|
141
|
+
const progressUpdatedAt = publicTime(step.progressUpdatedAt);
|
|
140
142
|
const node = {
|
|
141
143
|
id,
|
|
142
144
|
kind: "step",
|
|
@@ -146,6 +148,8 @@ function projectStep(step, index, depth, ctx) {
|
|
|
146
148
|
...(updatedAt !== undefined ? { updatedAt } : {}),
|
|
147
149
|
...(terminalState(state) && endedAt !== undefined ? { endedAt } : {}),
|
|
148
150
|
...(activity ? { activity } : {}),
|
|
151
|
+
...(progressText ? { progressText } : {}),
|
|
152
|
+
...(progressUpdatedAt !== undefined ? { progressUpdatedAt } : {}),
|
|
149
153
|
};
|
|
150
154
|
if (agent)
|
|
151
155
|
node.agent = agent;
|
|
@@ -302,6 +306,12 @@ function projectMaterializedStep(step, index, child, depth, ctx, childrenByParen
|
|
|
302
306
|
const selfActivity = selfStep ? activityFor(selfStep, ctx) : undefined;
|
|
303
307
|
const activity = laneActivity || selfActivity || live.activity ? { ...laneActivity, ...selfActivity, ...live.activity } : undefined;
|
|
304
308
|
const node = { ...live, id, kind: "step", label };
|
|
309
|
+
const progressText = publicOptionalText(selfStep?.progressText ?? step.progressText, ctx.caps.maxStringLength);
|
|
310
|
+
const progressUpdatedAt = publicTime(selfStep?.progressUpdatedAt ?? step.progressUpdatedAt);
|
|
311
|
+
if (progressText)
|
|
312
|
+
node.progressText = progressText;
|
|
313
|
+
if (progressUpdatedAt !== undefined)
|
|
314
|
+
node.progressUpdatedAt = progressUpdatedAt;
|
|
305
315
|
const agent = publicOptionalText(selfStep?.agent || step.agent, ctx.caps.maxStringLength);
|
|
306
316
|
if (agent)
|
|
307
317
|
node.agent = agent;
|
|
@@ -122,9 +122,9 @@ export interface ChildSession {
|
|
|
122
122
|
};
|
|
123
123
|
/** Event-updated pane-native status; reading it performs no network work. */
|
|
124
124
|
readonly placementSnapshot?: unknown;
|
|
125
|
-
/** Set by the foreground host once the run detached;
|
|
125
|
+
/** Set by the foreground host once the run detached; factory disposal leaves such children running. */
|
|
126
126
|
detached?: boolean;
|
|
127
|
-
/** Set by
|
|
127
|
+
/** Set by factory disposal before it aborts the child, so the host can report the stop truthfully. */
|
|
128
128
|
shutDown?: boolean;
|
|
129
129
|
}
|
|
130
130
|
export declare function childSessionHasQueuedMessages(session: ChildSession | undefined): boolean;
|
|
@@ -132,6 +132,8 @@ export interface ChildSessionFactory {
|
|
|
132
132
|
create(launch: ChildSessionLaunch): Promise<ChildSession>;
|
|
133
133
|
/** Abort and dispose every live attached child; detached children keep running and hold the shared runtime. */
|
|
134
134
|
dispose(): Promise<void>;
|
|
135
|
+
/** `dispose()` for only the children `parentSessionFile`'s session launched (undefined: sessions without a file); pi-web shuts sessions down one at a time. */
|
|
136
|
+
disposeForParent(parentSessionFile: string | undefined): Promise<void>;
|
|
135
137
|
}
|
|
136
138
|
export type PiCodingAgentModule = typeof import("@earendil-works/pi-coding-agent");
|
|
137
139
|
export interface DefaultChildSessionFactoryOptions {
|
|
@@ -175,6 +177,5 @@ export declare function setChildSessionFactory(factory: ChildSessionFactory | un
|
|
|
175
177
|
*/
|
|
176
178
|
export declare function childSessionFactoryModule(): string | undefined;
|
|
177
179
|
export declare function setChildSessionFactoryModule(modulePath: string | undefined): void;
|
|
178
|
-
|
|
179
|
-
export declare function disposeChildSessions(): Promise<void>;
|
|
180
|
+
export declare function disposeChildSessionsForParent(parentSessionFile: string | undefined): Promise<void>;
|
|
180
181
|
export {};
|
|
@@ -22,6 +22,7 @@ import { cleanupSessionResources, registerSessionResourceCleanup } from "@earend
|
|
|
22
22
|
import { CHILD_COMMAND_TOOL, createChildCommandRuntime } from "./child-commands.js";
|
|
23
23
|
import { supervisorChannelDir } from "./child-tool-plan.js";
|
|
24
24
|
import { pinChildCacheRetention } from "../../shared/child-cache-retention.js";
|
|
25
|
+
import { parseAcceptanceReport } from "./acceptance.js";
|
|
25
26
|
import { getAgentDir, PI_CODING_AGENT_PACKAGE_ROOT_ENV } from "../../shared/utils.js";
|
|
26
27
|
import { resolvePackageSubpath } from "../background/runner-aliases.js";
|
|
27
28
|
import { PI_CODING_AGENT_PACKAGE, resolveHostPiPackageRoot } from "./pi-spawn.js";
|
|
@@ -387,12 +388,15 @@ export function createDefaultChildSessionFactory(options = {}) {
|
|
|
387
388
|
const loadPiCodingAgent = options.loadPiCodingAgent ?? loadHostPiCodingAgent;
|
|
388
389
|
const shutdownTimeoutMs = options.shutdownTimeoutMs ?? 5_000;
|
|
389
390
|
let runtime;
|
|
390
|
-
const live = new
|
|
391
|
+
const live = new Map();
|
|
391
392
|
/** Extension shutdowns still running for disposed children; `dispose()` waits for them. */
|
|
392
393
|
const shutdowns = new Set();
|
|
393
394
|
/** Launches still waiting for their MCP tools; `dispose()` ends the wait and waits for their shutdown. */
|
|
394
395
|
const mcpWaits = new Map();
|
|
395
|
-
let
|
|
396
|
+
let globalDisposals = 0;
|
|
397
|
+
/** Per-parent disposal epochs: a child's launch aborts only when its own parent's scope (or the whole process) was disposed while it started. */
|
|
398
|
+
const parentDisposals = new Map();
|
|
399
|
+
const parentDisposalEpoch = (parent) => parentDisposals.get(parent) ?? 0;
|
|
396
400
|
const sharedRuntime = async (pi) => {
|
|
397
401
|
runtime ??= pi.ModelRuntime.create().catch((error) => {
|
|
398
402
|
runtime = undefined;
|
|
@@ -400,9 +404,32 @@ export function createDefaultChildSessionFactory(options = {}) {
|
|
|
400
404
|
});
|
|
401
405
|
return runtime;
|
|
402
406
|
};
|
|
407
|
+
const disposeMatching = async (matches) => {
|
|
408
|
+
for (const [cancel, wait] of mcpWaits)
|
|
409
|
+
if (matches(wait.parent))
|
|
410
|
+
cancel.abort();
|
|
411
|
+
const children = [...live.keys()].filter((child) => !child.detached && matches(live.get(child)));
|
|
412
|
+
for (const child of children)
|
|
413
|
+
child.shutDown = true;
|
|
414
|
+
await Promise.allSettled(children.map((child) => child.abort()));
|
|
415
|
+
for (const child of children) {
|
|
416
|
+
try {
|
|
417
|
+
void child.dispose();
|
|
418
|
+
}
|
|
419
|
+
catch { /* best effort */ }
|
|
420
|
+
}
|
|
421
|
+
await Promise.allSettled([
|
|
422
|
+
...shutdowns,
|
|
423
|
+
...[...mcpWaits.values()].filter((wait) => matches(wait.parent)).map((wait) => wait.ready),
|
|
424
|
+
]);
|
|
425
|
+
if (live.size === 0)
|
|
426
|
+
runtime = undefined;
|
|
427
|
+
};
|
|
403
428
|
return {
|
|
404
429
|
async create(launch) {
|
|
405
|
-
const
|
|
430
|
+
const globalDisposalsAtStart = globalDisposals;
|
|
431
|
+
const parentEpochAtStart = parentDisposalEpoch(launch.parentSessionFile);
|
|
432
|
+
const disposedSinceStart = () => globalDisposals !== globalDisposalsAtStart || parentDisposalEpoch(launch.parentSessionFile) !== parentEpochAtStart;
|
|
406
433
|
const pi = await loadPiCodingAgent();
|
|
407
434
|
const builtinMcpTools = launch.builtinMcpTools ?? [];
|
|
408
435
|
let readinessTool;
|
|
@@ -603,12 +630,12 @@ export function createDefaultChildSessionFactory(options = {}) {
|
|
|
603
630
|
if (builtinMcp) {
|
|
604
631
|
const cancel = new AbortController();
|
|
605
632
|
const signal = launch.signal ? AbortSignal.any([cancel.signal, launch.signal]) : cancel.signal;
|
|
606
|
-
if (
|
|
633
|
+
if (disposedSinceStart())
|
|
607
634
|
cancel.abort();
|
|
608
635
|
const ready = (async () => {
|
|
609
636
|
try {
|
|
610
637
|
await builtinMcp.waitForTools(signal, () => loader.getExtensions().errors.find(({ path }) => path === "builtin:mcp")?.error);
|
|
611
|
-
if (
|
|
638
|
+
if (disposedSinceStart())
|
|
612
639
|
throw new Error("The child session factory was disposed while the child waited for its MCP tools.");
|
|
613
640
|
if (signal.aborted)
|
|
614
641
|
throw new Error("The child launch was cancelled while waiting for its MCP tools.");
|
|
@@ -621,7 +648,7 @@ export function createDefaultChildSessionFactory(options = {}) {
|
|
|
621
648
|
throw error;
|
|
622
649
|
}
|
|
623
650
|
})();
|
|
624
|
-
mcpWaits.set(cancel, ready);
|
|
651
|
+
mcpWaits.set(cancel, { ready, parent: launch.parentSessionFile });
|
|
625
652
|
try {
|
|
626
653
|
await ready;
|
|
627
654
|
}
|
|
@@ -629,12 +656,29 @@ export function createDefaultChildSessionFactory(options = {}) {
|
|
|
629
656
|
mcpWaits.delete(cancel);
|
|
630
657
|
}
|
|
631
658
|
}
|
|
659
|
+
let reportCompleted = false;
|
|
660
|
+
const guidanceClosed = "Child completed its acceptance report; resume it for further guidance.";
|
|
661
|
+
const assertAcceptsGuidance = () => { if (reportCompleted)
|
|
662
|
+
throw new Error(guidanceClosed); };
|
|
663
|
+
const rejectQueuedGuidance = () => { session.clearQueue(); throw new Error(guidanceClosed); };
|
|
632
664
|
const child = {
|
|
633
|
-
subscribe: (listener) => session.subscribe((event) =>
|
|
665
|
+
subscribe: (listener) => session.subscribe((event) => {
|
|
666
|
+
if (event.type === "message_end" && event.message.role === "assistant" && event.message.stopReason === "stop") {
|
|
667
|
+
const text = event.message.content.filter((part) => part.type === "text").map((part) => part.text).join("\n");
|
|
668
|
+
const report = parseAcceptanceReport(text);
|
|
669
|
+
if (report.report || report.malformed) {
|
|
670
|
+
reportCompleted = true;
|
|
671
|
+
session.clearQueue();
|
|
672
|
+
session.agent.steer = rejectQueuedGuidance;
|
|
673
|
+
session.agent.followUp = rejectQueuedGuidance;
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
listener(event);
|
|
677
|
+
}),
|
|
634
678
|
prompt: (text) => session.prompt(text),
|
|
635
679
|
...(commands ? { finishCommands: () => commands.finish() } : {}),
|
|
636
|
-
steer: async (text) => { await session.steer(text); },
|
|
637
|
-
followUp: async (text) => { await session.followUp(text); },
|
|
680
|
+
steer: async (text) => { assertAcceptsGuidance(); await session.steer(text); },
|
|
681
|
+
followUp: async (text) => { assertAcceptsGuidance(); await session.followUp(text); },
|
|
638
682
|
abort: () => session.abort(),
|
|
639
683
|
hasQueuedMessages: () => session.agent?.hasQueuedMessages?.() === true,
|
|
640
684
|
dispose: () => {
|
|
@@ -656,26 +700,16 @@ export function createDefaultChildSessionFactory(options = {}) {
|
|
|
656
700
|
get virtualModelId() { return session.model?.api === "pi-virtual" ? `${session.model.provider}/${session.model.id}` : undefined; },
|
|
657
701
|
get contextWindow() { return session.model?.contextWindow; },
|
|
658
702
|
};
|
|
659
|
-
live.
|
|
703
|
+
live.set(child, launch.parentSessionFile);
|
|
660
704
|
return child;
|
|
661
705
|
},
|
|
662
706
|
async dispose() {
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
await Promise.allSettled(children.map((child) => child.abort()));
|
|
670
|
-
for (const child of children) {
|
|
671
|
-
try {
|
|
672
|
-
void child.dispose();
|
|
673
|
-
}
|
|
674
|
-
catch { /* best effort */ }
|
|
675
|
-
}
|
|
676
|
-
await Promise.allSettled([...shutdowns, ...mcpWaits.values()]);
|
|
677
|
-
if (live.size === 0)
|
|
678
|
-
runtime = undefined;
|
|
707
|
+
globalDisposals += 1;
|
|
708
|
+
await disposeMatching(() => true);
|
|
709
|
+
},
|
|
710
|
+
async disposeForParent(parentSessionFile) {
|
|
711
|
+
parentDisposals.set(parentSessionFile, parentDisposalEpoch(parentSessionFile) + 1);
|
|
712
|
+
await disposeMatching((parent) => parent === parentSessionFile);
|
|
679
713
|
},
|
|
680
714
|
};
|
|
681
715
|
}
|
|
@@ -691,10 +725,8 @@ function createLazyPlacementFactory(local) {
|
|
|
691
725
|
const factory = async () => placed ??= (await import("./herdr-placed-run.js")).createPlacementAwareChildSessionFactory(local);
|
|
692
726
|
return {
|
|
693
727
|
async create(launch) { return launch.machine ? (await factory()).create(launch) : local.create(launch); },
|
|
694
|
-
async dispose() {
|
|
695
|
-
|
|
696
|
-
else
|
|
697
|
-
await local.dispose(); },
|
|
728
|
+
async dispose() { await (placed ?? local).dispose(); },
|
|
729
|
+
async disposeForParent(parentSessionFile) { await (placed ?? local).disposeForParent(parentSessionFile); },
|
|
698
730
|
};
|
|
699
731
|
}
|
|
700
732
|
/** Default factory including pane-native placement; detached runners use the same boundary. */
|
|
@@ -719,10 +751,6 @@ export function childSessionFactoryModule() {
|
|
|
719
751
|
export function setChildSessionFactoryModule(modulePath) {
|
|
720
752
|
activeFactoryModule = modulePath;
|
|
721
753
|
}
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
const factory = activeFactory;
|
|
725
|
-
if (!factory)
|
|
726
|
-
return;
|
|
727
|
-
await factory.dispose();
|
|
754
|
+
export async function disposeChildSessionsForParent(parentSessionFile) {
|
|
755
|
+
await activeFactory?.disposeForParent(parentSessionFile);
|
|
728
756
|
}
|
|
@@ -399,7 +399,8 @@ async function startPlacedPiSession(launch, owner, policy) {
|
|
|
399
399
|
}
|
|
400
400
|
function createPlacedPiSession(launch) { return launch.machine?.provider === "rex" ? createRexPiSession(launch) : createHerdrPiSession(launch); }
|
|
401
401
|
export function createPlacementAwareChildSessionFactory(local, createRemote = createPlacedPiSession) {
|
|
402
|
-
const remote = new
|
|
402
|
+
const remote = new Map();
|
|
403
403
|
return { async create(launch) { if (!launch.machine)
|
|
404
|
-
return local.create(launch); serializeHerdrPiLaunch(launch); const child = await createRemote(launch); remote.
|
|
404
|
+
return local.create(launch); serializeHerdrPiLaunch(launch); const child = await createRemote(launch); remote.set(child, launch.parentSessionFile); return child; }, async dispose() { await Promise.allSettled([...remote.keys()].map((child) => child.dispose())); remote.clear(); await local.dispose(); }, async disposeForParent(parentSessionFile) { const matching = [...remote].filter(([, parent]) => parent === parentSessionFile).map(([child]) => child); await Promise.allSettled(matching.map((child) => child.dispose())); for (const child of matching)
|
|
405
|
+
remote.delete(child); await local.disposeForParent(parentSessionFile); } };
|
|
405
406
|
}
|
|
@@ -22,11 +22,14 @@ export interface McpServerDefinition {
|
|
|
22
22
|
/** Per-server override of the global `settings.toolPrefix`, matching the adapter. */
|
|
23
23
|
toolPrefix?: McpToolPrefix;
|
|
24
24
|
protocolVersion?: string;
|
|
25
|
-
|
|
25
|
+
/** Validated so adapter configs load; `mcp:` selectors do not read it. */
|
|
26
|
+
directTools?: boolean | string[] | "search";
|
|
26
27
|
httpTransport?: string;
|
|
27
28
|
pluginDataDir?: string;
|
|
28
29
|
literalEnv?: boolean;
|
|
29
30
|
inheritEnv?: boolean;
|
|
31
|
+
/** Only literal true disables a server, matching pi-mcp-adapter. */
|
|
32
|
+
disabled?: boolean;
|
|
30
33
|
}
|
|
31
34
|
export declare function isMcpServerDefinition(value: unknown): value is McpServerDefinition;
|
|
32
35
|
export declare function loadPackageMcpServers(cwd: string): Record<string, McpServerDefinition>;
|
|
@@ -33,7 +33,7 @@ export function isMcpServerDefinition(value) {
|
|
|
33
33
|
return false;
|
|
34
34
|
if (value.auth !== undefined && value.auth !== "oauth" && value.auth !== "bearer" && value.auth !== false)
|
|
35
35
|
return false;
|
|
36
|
-
return value.directTools === undefined || typeof value.directTools === "boolean" || isStringArray(value.directTools);
|
|
36
|
+
return value.directTools === undefined || typeof value.directTools === "boolean" || value.directTools === "search" || isStringArray(value.directTools);
|
|
37
37
|
}
|
|
38
38
|
function isRecord(value) {
|
|
39
39
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
@@ -17,7 +17,6 @@ export interface McpConfig {
|
|
|
17
17
|
imports?: ImportKind[];
|
|
18
18
|
settings?: {
|
|
19
19
|
toolPrefix?: McpToolPrefix;
|
|
20
|
-
directTools?: boolean;
|
|
21
20
|
agentPluginPaths?: unknown;
|
|
22
21
|
};
|
|
23
22
|
}
|
|
@@ -74,7 +73,6 @@ export interface McpDirectToolResolution {
|
|
|
74
73
|
builtin?: true;
|
|
75
74
|
}
|
|
76
75
|
export declare function resolveMcpDirectToolResolution(mcpDirectTools: string[] | undefined, cwd?: string, runtimeSnapshotHost?: McpRuntimeSnapshotHost, configOverride?: McpConfig): McpDirectToolResolution;
|
|
77
|
-
export declare function resolveMcpDirectToolSelections(mcpDirectTools: string[] | undefined, cwd?: string, runtimeSnapshotHost?: McpRuntimeSnapshotHost): ResolvedMcpDirectToolSelection[];
|
|
78
76
|
export declare function formatUnresolvedBuiltinMcpSelectors(agentName: string | undefined, selectors: readonly string[]): string;
|
|
79
77
|
/**
|
|
80
78
|
* Selected servers that only an extension registered, which a child without ambient extensions
|
|
@@ -82,5 +80,4 @@ export declare function formatUnresolvedBuiltinMcpSelectors(agentName: string |
|
|
|
82
80
|
* the project file is read only when the project is trusted.
|
|
83
81
|
*/
|
|
84
82
|
export declare function extensionOnlyMcpServers(selections: readonly ResolvedMcpDirectToolSelection[], host: McpRuntimeSnapshotHost, cwd: string, projectTrusted: boolean): string[];
|
|
85
|
-
export declare function resolveMcpDirectToolNames(mcpDirectTools: string[] | undefined, cwd?: string): string[];
|
|
86
83
|
export declare function computeMcpServerHash(definition: ServerEntry): string;
|