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-ZJJCPV3L.js → chunk-47GJDBIK.js} +10 -6
- package/bundle/{chunk-77ASNIEM.js → chunk-47ZN7NKR.js} +1 -1
- package/bundle/{chunk-QGO6HXHG.js → chunk-4MVDMA5C.js} +88 -64
- package/bundle/{chunk-O3YH7XIY.js → chunk-4PM6RDE5.js} +46 -32
- package/bundle/{chunk-BWC2LVII.js → chunk-4UGWHREQ.js} +200 -64
- package/bundle/{chunk-3RKFH2UZ.js → chunk-6EUQPQY7.js} +31 -14
- package/bundle/{chunk-A637IMAO.js → chunk-6OWNDN7R.js} +2 -2
- package/bundle/{chunk-6VD7BGIC.js → chunk-6PR44R7E.js} +7 -2
- 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-NAFLUJ26.js → chunk-KXW62VBU.js} +1 -1
- package/bundle/{chunk-S2Q75LP3.js → chunk-L4YY2TOE.js} +1 -1
- package/bundle/{chunk-QM3JGE4W.js → chunk-MTPICU4A.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-7ADDXUGF.js → chunk-UVDLJXL6.js} +14 -5
- package/bundle/{chunk-NF7IEKBH.js → chunk-W2BZS6UC.js} +27 -13
- package/bundle/{chunk-5H4BICQZ.js → chunk-W6HIYD2Z.js} +1 -1
- package/bundle/{chunk-2IYBCYFU.js → chunk-XAOHLFJO.js} +174 -56
- package/bundle/{chunk-LGINOOY5.js → chunk-XIA5GSEU.js} +2 -2
- 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 +17 -5
- 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 +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 +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 +1 -0
- package/src/extension/config.js +6 -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,
|
|
@@ -2708,18 +2713,6 @@ function timerDelayOverflowError(name, value) {
|
|
|
2708
2713
|
? `${name} must be a positive integer no larger than ${MAX_TIMER_DELAY_MS}.`
|
|
2709
2714
|
: undefined;
|
|
2710
2715
|
}
|
|
2711
|
-
/**
|
|
2712
|
-
* Resolve the optional global default runtime deadline from extension config
|
|
2713
|
-
* (`config.timeoutMs`). Returns undefined for unset or invalid values so callers
|
|
2714
|
-
* fall back to the built-in defaults. "Invalid" covers non-positive-integer
|
|
2715
|
-
* values and values above `MAX_TIMER_DELAY_MS`; the latter would overflow the
|
|
2716
|
-
* Node.js timer and expire the run almost immediately instead of running long.
|
|
2717
|
-
*/
|
|
2718
|
-
export function resolveConfigDefaultTimeoutMs(raw) {
|
|
2719
|
-
if (typeof raw !== "number" || !Number.isInteger(raw) || raw <= 0 || raw > MAX_TIMER_DELAY_MS)
|
|
2720
|
-
return undefined;
|
|
2721
|
-
return raw;
|
|
2722
|
-
}
|
|
2723
2716
|
export function resolveForegroundTimeout(params, defaultTimeoutMs) {
|
|
2724
2717
|
const rawTimeout = params.timeoutMs;
|
|
2725
2718
|
const rawMaxRuntime = params.maxRuntimeMs;
|
|
@@ -2874,7 +2867,7 @@ function resolveStaticLaunchSummary(input) {
|
|
|
2874
2867
|
const modelScopes = resolveModelScopesForAgent(input.modelScope, input.agent, input.parentModel, input.scopedModelIds);
|
|
2875
2868
|
const model = externalRunner
|
|
2876
2869
|
? undefined
|
|
2877
|
-
: resolveEffectiveSubagentModel(input.explicitModel, agentConfig?.model, input.parentModel, input.availableModels, agentConfig?.modelProvider ?? input.currentProvider,
|
|
2870
|
+
: resolveEffectiveSubagentModel(input.explicitModel, agentConfig?.model, input.parentModel, input.availableModels, agentConfig?.modelProvider ?? input.currentProvider, { scope: modelScopes, knownProviders: input.knownProviders });
|
|
2878
2871
|
const thinkingOverride = externalRunner ? undefined : input.thinkingOverrideForTask();
|
|
2879
2872
|
const thinking = externalRunner ? undefined : resolveEffectiveThinking(model, thinkingOverride ?? agentConfig?.thinking);
|
|
2880
2873
|
return {
|
|
@@ -2892,6 +2885,7 @@ function collectStaticLaunchSummaries(input) {
|
|
|
2892
2885
|
parentModel: input.parentModel,
|
|
2893
2886
|
scopedModelIds: input.scopedModelIds,
|
|
2894
2887
|
availableModels: input.availableModels,
|
|
2888
|
+
knownProviders: input.knownProviders,
|
|
2895
2889
|
currentProvider: input.currentProvider,
|
|
2896
2890
|
modelScope: input.modelScope,
|
|
2897
2891
|
thinkingOverrideForTask: input.thinkingOverrideForTask,
|
|
@@ -3171,6 +3165,7 @@ async function runAsyncPath(data, deps) {
|
|
|
3171
3165
|
parentProviderRegistry: ctx.modelRegistry,
|
|
3172
3166
|
currentModel: parentModel,
|
|
3173
3167
|
scopedModelIds: data.scopedModelIds,
|
|
3168
|
+
knownProviders: knownModelProviders(ctx.modelRegistry),
|
|
3174
3169
|
modelScope: data.modelScope,
|
|
3175
3170
|
modelResponseAliases: deps.config.modelResponseAliases,
|
|
3176
3171
|
runnerLaunchers: deps.config.runnerLaunchers,
|
|
@@ -3215,8 +3210,9 @@ async function runAsyncPath(data, deps) {
|
|
|
3215
3210
|
const modelOverride = a.runner?.type === "external-cli" || a.runner?.type === "external-job"
|
|
3216
3211
|
? params.model ?? (externalRunnerWithoutExplicitModel ? undefined : a.model)
|
|
3217
3212
|
: resolveEffectiveSubagentModel(params.model, a.model, parentModel, availableModels, a.modelProvider ?? currentProvider, {
|
|
3218
|
-
|
|
3213
|
+
scope: modelScopes,
|
|
3219
3214
|
source: modelOrigin === "explicit" ? "explicit" : "inherited",
|
|
3215
|
+
knownProviders: asyncCtx.knownProviders,
|
|
3220
3216
|
});
|
|
3221
3217
|
const modelOverrideFromParent = modelOrigin === "inherited";
|
|
3222
3218
|
const launchRuleError = applyWatchdogLaunchRules({ cwd: effectiveCwd, agent: a.name, model: modelOverride ?? (parentModel && `${parentModel.provider}/${parentModel.id}`), warn: (violation) => deps.watchdog?.displayRuleWarning(violation) });
|
|
@@ -3644,6 +3640,7 @@ async function runSinglePath(data, deps) {
|
|
|
3644
3640
|
const parentModel = data.parentModel;
|
|
3645
3641
|
const currentProvider = parentModel?.provider;
|
|
3646
3642
|
const availableModels = ctx.modelRegistry.getAvailable().map(toModelInfo);
|
|
3643
|
+
const knownProviders = knownModelProviders(ctx.modelRegistry);
|
|
3647
3644
|
const modelScopes = resolveModelScopesForAgent(data.modelScope, agentConfig.name, parentModel, data.scopedModelIds);
|
|
3648
3645
|
let task = typeof params.task === "string" ? params.task : "";
|
|
3649
3646
|
const modelOrigin = resolveModelOrigin({
|
|
@@ -3653,8 +3650,9 @@ async function runSinglePath(data, deps) {
|
|
|
3653
3650
|
parentModel,
|
|
3654
3651
|
});
|
|
3655
3652
|
let modelOverride = resolveEffectiveSubagentModel(params.model, agentConfig.model, parentModel, availableModels, agentConfig.modelProvider ?? currentProvider, {
|
|
3656
|
-
|
|
3653
|
+
scope: modelScopes,
|
|
3657
3654
|
source: modelOrigin === "explicit" ? "explicit" : "inherited",
|
|
3655
|
+
knownProviders,
|
|
3658
3656
|
});
|
|
3659
3657
|
const modelOverrideFromParent = modelOrigin === "inherited";
|
|
3660
3658
|
const launchRuleError = applyWatchdogLaunchRules({ cwd: effectiveCwd, agent: agentConfig.name, model: modelOverride ?? (parentModel && `${parentModel.provider}/${parentModel.id}`), warn: (violation) => deps.watchdog?.displayRuleWarning(violation) });
|
|
@@ -3902,6 +3900,7 @@ async function runSinglePath(data, deps) {
|
|
|
3902
3900
|
thinkingCeiling: agentConfig.maxThinking,
|
|
3903
3901
|
extensionBindings: params.extensionBindings,
|
|
3904
3902
|
availableModels,
|
|
3903
|
+
knownProviders,
|
|
3905
3904
|
modelResponseAliases,
|
|
3906
3905
|
preferredModelProvider: currentProvider,
|
|
3907
3906
|
modelScope: modelScopes,
|
|
@@ -5179,6 +5178,7 @@ export function createSubagentExecutor(deps) {
|
|
|
5179
5178
|
const controller = new AbortController();
|
|
5180
5179
|
deps.state.workflowControllers ??= new Map();
|
|
5181
5180
|
deps.state.workflowChildStops ??= new Map();
|
|
5181
|
+
deps.state.workflowDrains ??= new Map();
|
|
5182
5182
|
deps.state.workflowControllers.set(workflowRunId, controller);
|
|
5183
5183
|
workflowCapacity?.markWorkflowStarted();
|
|
5184
5184
|
if (workflowCapacity)
|
|
@@ -5809,6 +5809,36 @@ export function createSubagentExecutor(deps) {
|
|
|
5809
5809
|
else
|
|
5810
5810
|
deps.state.workflowChildStops?.delete(workflowRunId);
|
|
5811
5811
|
},
|
|
5812
|
+
registerDrain: (drain) => {
|
|
5813
|
+
if (!drain)
|
|
5814
|
+
deps.state.workflowDrains?.delete(workflowRunId);
|
|
5815
|
+
else
|
|
5816
|
+
deps.state.workflowDrains?.set(workflowRunId, () => {
|
|
5817
|
+
if (workflowRunEvidence.drainRequestedAt === undefined) {
|
|
5818
|
+
// The marker must be on disk before anything is stopped: without it a reload during the drain would resume the run.
|
|
5819
|
+
const previousWorkflow = status.workflow;
|
|
5820
|
+
workflowRunEvidence.drainRequestedAt = Date.now();
|
|
5821
|
+
status.workflow = { ...(previousWorkflow ?? { trace: [], emits: [], console: [] }), drainRequestedAt: workflowRunEvidence.drainRequestedAt };
|
|
5822
|
+
let saved = false;
|
|
5823
|
+
try {
|
|
5824
|
+
persist();
|
|
5825
|
+
saved = runPersistence.pendingCount() === 0;
|
|
5826
|
+
}
|
|
5827
|
+
catch (error) {
|
|
5828
|
+
console.error(`Failed to save the drain request for async workflow '${workflowRunId}':`, error);
|
|
5829
|
+
}
|
|
5830
|
+
if (!saved) {
|
|
5831
|
+
delete workflowRunEvidence.drainRequestedAt;
|
|
5832
|
+
status.workflow = previousWorkflow;
|
|
5833
|
+
// Replaces a queued write that still carries the marker.
|
|
5834
|
+
persist({ tolerateStatusWriteFailure: true });
|
|
5835
|
+
return { ok: false };
|
|
5836
|
+
}
|
|
5837
|
+
}
|
|
5838
|
+
// Deferred so a full stop that stops the last running child aborts with its own reason first.
|
|
5839
|
+
return { ok: true, started: drain(() => queueMicrotask(() => controller.abort(new Error("Workflow drained: started children finished; no new children were started.")))) };
|
|
5840
|
+
});
|
|
5841
|
+
},
|
|
5812
5842
|
...(workflowState ? { state: workflowState } : {}),
|
|
5813
5843
|
onTrace: updateTrace,
|
|
5814
5844
|
onChildSettled: (notification) => {
|
|
@@ -5972,6 +6002,8 @@ export function createSubagentExecutor(deps) {
|
|
|
5972
6002
|
step.currentToolArgs = progress.currentToolArgs;
|
|
5973
6003
|
step.currentToolStartedAt = progress.currentToolStartedAt;
|
|
5974
6004
|
step.currentPath = progress.currentPath;
|
|
6005
|
+
step.progressText = progress.progressText;
|
|
6006
|
+
step.progressUpdatedAt = progress.progressUpdatedAt;
|
|
5975
6007
|
step.recentTools = progress.recentTools.map((tool) => ({ ...tool }));
|
|
5976
6008
|
step.recentOutput = [...progress.recentOutput];
|
|
5977
6009
|
step.turnCount = progress.turnCount;
|
|
@@ -6151,8 +6183,7 @@ export function createSubagentExecutor(deps) {
|
|
|
6151
6183
|
const workflowOutput = typeof workflowChildDefaults.output === "string" || typeof workflowChildDefaults.output === "boolean" ? workflowChildDefaults.output : undefined;
|
|
6152
6184
|
const configuredOutputBaseDir = resolveConfiguredSingleRunOutputBaseDir(deps);
|
|
6153
6185
|
const workflowAggregateOutputPath = resolveSingleOutputPath(workflowOutput, ctx.cwd, workflowCwd, resolveSingleRunOutputBaseDir(deps, workflowArtifactsDir, foregroundWorkflowRunId));
|
|
6154
|
-
//
|
|
6155
|
-
// within artifact retention, which only removes top-level files.
|
|
6186
|
+
// Outside outputs/ so it cannot overwrite a child's report.
|
|
6156
6187
|
const workflowFullResultPath = path.join(workflowArtifactsDir, `${sanitizeRunPathSegment(foregroundWorkflowRunId)}_workflow-result.md`);
|
|
6157
6188
|
const claimedOutputPaths = new Map();
|
|
6158
6189
|
const childOutputOverrides = new Map();
|
|
@@ -7039,6 +7070,8 @@ export function createSubagentExecutor(deps) {
|
|
|
7039
7070
|
}
|
|
7040
7071
|
if (action === "stop") {
|
|
7041
7072
|
const targetRunId = paramsWithResolvedCwd.runId ?? paramsWithResolvedCwd.id;
|
|
7073
|
+
if (paramsWithResolvedCwd.drain && paramsWithResolvedCwd.childId !== undefined)
|
|
7074
|
+
return { content: [{ type: "text", text: "action='stop' drain applies to a whole workflow; omit childId." }], isError: true, details: { mode: "management", results: [] } };
|
|
7042
7075
|
// Whole-workflow stops reach stopAsyncRun below, which stops a live workflow in-process.
|
|
7043
7076
|
const workflowRunId = targetRunId && paramsWithResolvedCwd.childId !== undefined ? resolveLiveWorkflowRunId(deps, targetRunId) : undefined;
|
|
7044
7077
|
if (workflowRunId && paramsWithResolvedCwd.childId !== undefined) {
|
|
@@ -7085,7 +7118,7 @@ export function createSubagentExecutor(deps) {
|
|
|
7085
7118
|
if (paramsWithResolvedCwd.dir) {
|
|
7086
7119
|
try {
|
|
7087
7120
|
const location = resolveAsyncRunLocation(paramsWithResolvedCwd, DIRS.async, DIRS.results);
|
|
7088
|
-
const stopResult = stopAsyncRun(deps.state, location.resolvedId ?? targetRunId ?? path.basename(location.asyncDir ?? paramsWithResolvedCwd.dir), deps.kill, location, paramsWithResolvedCwd.childId);
|
|
7121
|
+
const stopResult = stopAsyncRun(deps.state, location.resolvedId ?? targetRunId ?? path.basename(location.asyncDir ?? paramsWithResolvedCwd.dir), deps.kill, location, paramsWithResolvedCwd.childId, paramsWithResolvedCwd.drain);
|
|
7089
7122
|
return stopResult ?? { content: [{ type: "text", text: `No running or queued async run was found for '${targetRunId ?? paramsWithResolvedCwd.dir}'.` }], isError: true, details: { mode: "management", results: [] } };
|
|
7090
7123
|
}
|
|
7091
7124
|
catch (error) {
|
|
@@ -7106,7 +7139,7 @@ export function createSubagentExecutor(deps) {
|
|
|
7106
7139
|
return { content: [{ type: "text", text: "action='stop' supports current-session top-level async runs only." }], isError: true, details: { mode: "management", results: [] } };
|
|
7107
7140
|
if (resolved?.kind === "foreground")
|
|
7108
7141
|
return { content: [{ type: "text", text: "action='stop' supports async runs only. Use action='interrupt' for foreground runs." }], isError: true, details: { mode: "management", results: [] } };
|
|
7109
|
-
const stopResult = stopAsyncRun(deps.state, resolved?.kind === "async" ? resolved.id : targetRunId, deps.kill, resolved?.kind === "async" ? resolved.location : undefined, paramsWithResolvedCwd.childId);
|
|
7142
|
+
const stopResult = stopAsyncRun(deps.state, resolved?.kind === "async" ? resolved.id : targetRunId, deps.kill, resolved?.kind === "async" ? resolved.location : undefined, paramsWithResolvedCwd.childId, paramsWithResolvedCwd.drain);
|
|
7110
7143
|
if (stopResult)
|
|
7111
7144
|
return stopResult;
|
|
7112
7145
|
return {
|
|
@@ -7651,6 +7684,7 @@ export function createSubagentExecutor(deps) {
|
|
|
7651
7684
|
parentModel: requestParentModel,
|
|
7652
7685
|
scopedModelIds: scopedModelIdsFromContext(ctx),
|
|
7653
7686
|
availableModels: ctx.modelRegistry.getAvailable().map(toModelInfo),
|
|
7687
|
+
knownProviders: knownModelProviders(ctx.modelRegistry),
|
|
7654
7688
|
currentProvider: requestParentModel?.provider,
|
|
7655
7689
|
modelScope,
|
|
7656
7690
|
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;
|