@vicary/pi-subagents 0.86.0 → 0.88.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +59 -0
- package/bundle/agents.js +3 -3
- package/bundle/child-tool-plan.js +2 -2
- package/bundle/{chunk-PYOAIN3V.js → chunk-2DIEL4WG.js} +2 -2
- package/bundle/{chunk-GJGTMLPE.js → chunk-3DT5X2QC.js} +483 -477
- package/bundle/{chunk-374MZFF4.js → chunk-3MFYKBKI.js} +23 -13
- package/bundle/{chunk-77ASNIEM.js → chunk-47ZN7NKR.js} +1 -1
- package/bundle/{chunk-QGO6HXHG.js → chunk-4MVDMA5C.js} +88 -64
- package/bundle/{chunk-3RKFH2UZ.js → chunk-6EUQPQY7.js} +31 -14
- package/bundle/{chunk-6VD7BGIC.js → chunk-6PR44R7E.js} +7 -2
- package/bundle/{chunk-DD22RXYJ.js → chunk-AOSILI5R.js} +200 -64
- package/bundle/{chunk-WHC2XHGF.js → chunk-BW5JLKIU.js} +174 -56
- package/bundle/{chunk-7ZUFN6ME.js → chunk-CKLZ5FGU.js} +2 -2
- package/bundle/{chunk-ZPY5QZCS.js → chunk-CYKNHFXB.js} +1 -1
- package/bundle/{chunk-YK3QYNLE.js → chunk-GDR2ILWY.js} +1 -1
- package/bundle/{chunk-7QA7ZA46.js → chunk-IZEKQEY4.js} +9 -9
- package/bundle/{chunk-CJHFDQFJ.js → chunk-JYHTDTOZ.js} +10 -6
- package/bundle/{chunk-NAFLUJ26.js → chunk-KXW62VBU.js} +1 -1
- package/bundle/{chunk-S2Q75LP3.js → chunk-L4YY2TOE.js} +1 -1
- package/bundle/{chunk-2DITXA3H.js → chunk-NVGQE2H2.js} +12 -12
- package/bundle/{chunk-BU6PFPVX.js → chunk-PJSOS2Q4.js} +12 -7
- package/bundle/{chunk-UR7OW5S7.js → chunk-RHYVKQQL.js} +11 -5
- package/bundle/{chunk-BGXEAYUM.js → chunk-SVIXQDIV.js} +20 -5
- package/bundle/{chunk-GLVJMI6R.js → chunk-TDJKY2NE.js} +14 -5
- package/bundle/{chunk-XOFYXQKZ.js → chunk-V7SZMS6W.js} +2 -2
- package/bundle/{chunk-NF7IEKBH.js → chunk-W2BZS6UC.js} +27 -13
- package/bundle/{chunk-5H4BICQZ.js → chunk-W6HIYD2Z.js} +1 -1
- package/bundle/{chunk-LGINOOY5.js → chunk-XIA5GSEU.js} +2 -2
- package/bundle/{chunk-QFLPV64W.js → chunk-XZXYPZUT.js} +46 -32
- package/bundle/chunk-YDZ7BZD5.js +523 -0
- package/bundle/{chunk-WN2E5XHN.js → chunk-YZPVALSQ.js} +30 -5
- package/bundle/control-channel.js +2 -2
- package/bundle/index.js +1 -1
- package/bundle/intercom-bridge.js +2 -2
- package/bundle/preflight.js +12 -10
- package/bundle/project-panes.js +3 -3
- package/bundle/workflow-resources.js +1 -1
- package/docs/agents.md +4 -4
- package/docs/configuration.md +14 -4
- package/docs/extension-api.md +2 -0
- package/docs/models.md +6 -2
- package/docs/observability.md +2 -0
- package/docs/tool-reference.md +5 -1
- package/package.json +3 -3
- package/skills/pi-subagents/SKILL.md +15 -6
- package/skills/pi-subagents/references/prompting-and-roles.md +1 -0
- package/src/agents/agent-management.d.ts +1 -0
- package/src/agents/agent-management.js +22 -10
- package/src/agents/agent-serializer.d.ts +2 -0
- package/src/agents/agent-serializer.js +1 -1
- package/src/agents/agents.d.ts +1 -0
- package/src/agents/agents.js +39 -14
- package/src/api/preflight.d.ts +3 -1
- package/src/api/preflight.js +2 -0
- package/src/extension/config.d.ts +9 -0
- package/src/extension/config.js +13 -0
- package/src/extension/index.js +8 -5
- package/src/extension/schemas.d.ts +4 -0
- package/src/extension/schemas.js +2 -0
- package/src/extension/tool-activation.js +20 -3
- package/src/runs/background/async-execution.d.ts +2 -1
- package/src/runs/background/async-execution.js +4 -2
- package/src/runs/background/async-resume.js +2 -1
- package/src/runs/background/async-retention.d.ts +0 -2
- package/src/runs/background/async-retention.js +11 -5
- package/src/runs/background/async-status.d.ts +2 -0
- package/src/runs/background/async-status.js +4 -0
- package/src/runs/background/run-child-session.d.ts +2 -2
- package/src/runs/background/run-child-session.js +4 -7
- package/src/runs/background/runner-aliases.js +15 -0
- package/src/runs/background/steering.d.ts +2 -11
- package/src/runs/background/steering.js +11 -6
- package/src/runs/background/subagent-runner.d.ts +0 -2
- package/src/runs/background/subagent-runner.js +73 -58
- package/src/runs/background/wait-subscriptions.js +124 -12
- package/src/runs/foreground/async-steering-action.js +24 -9
- package/src/runs/foreground/async-stop-action.d.ts +1 -1
- package/src/runs/foreground/async-stop-action.js +9 -1
- package/src/runs/foreground/execution.js +33 -15
- package/src/runs/foreground/prompt-audit.js +1 -0
- package/src/runs/foreground/subagent-executor.d.ts +2 -8
- package/src/runs/foreground/subagent-executor.js +57 -23
- package/src/runs/shared/async-status-projection.d.ts +2 -0
- package/src/runs/shared/async-status-projection.js +10 -0
- package/src/runs/shared/child-session.d.ts +5 -4
- package/src/runs/shared/child-session.js +64 -36
- package/src/runs/shared/herdr-placed-run.js +3 -2
- package/src/runs/shared/mcp-config-sources.d.ts +4 -1
- package/src/runs/shared/mcp-config-sources.js +1 -1
- package/src/runs/shared/mcp-direct-tool-allowlist.d.ts +0 -3
- package/src/runs/shared/mcp-direct-tool-allowlist.js +26 -17
- package/src/runs/shared/model-resolution.d.ts +19 -4
- package/src/runs/shared/model-resolution.js +50 -51
- package/src/runs/shared/subagent-prompt-runtime.js +14 -2
- package/src/runs/shared/supervisor-wait-timer.d.ts +16 -0
- package/src/runs/shared/supervisor-wait-timer.js +61 -0
- package/src/shared/artifacts.d.ts +1 -0
- package/src/shared/artifacts.js +132 -22
- package/src/shared/pruned-fork.js +2 -2
- package/src/shared/reported-progress.d.ts +1 -0
- package/src/shared/reported-progress.js +12 -0
- package/src/shared/status-format.d.ts +1 -0
- package/src/shared/status-format.js +1 -1
- package/src/shared/types.d.ts +23 -0
- package/src/shared/utils.d.ts +3 -1
- package/src/shared/utils.js +4 -0
- package/src/tui/render.js +33 -2
- package/src/watchdog/model-selection.js +2 -2
- package/src/watchdog/permission-arbiter.js +1 -0
- package/src/watchdog/review.d.ts +0 -5
- package/src/watchdog/review.js +4 -3
- package/src/workflows/scripted-workflow.d.ts +2 -0
- package/src/workflows/scripted-workflow.js +103 -39
- package/src/workflows/structured-workflow-scripts.d.ts +4 -3
- package/src/workflows/structured-workflow-scripts.js +32 -11
- package/src/workflows/workflow-resources.js +4 -4
- package/src/workflows/workflow-resume-claim.d.ts +2 -0
- package/src/workflows/workflow-resume-claim.js +1 -1
- package/src/workflows/workflow-resume.d.ts +1 -1
- package/src/workflows/workflow-resume.js +3 -1
- package/src/workflows/workflow-script-worker.js +3 -1
- package/bundle/chunk-GRJHIXYF.js +0 -235
package/src/agents/agents.js
CHANGED
|
@@ -84,7 +84,7 @@ export function unknownAgentDiagnosticContext(discovered) {
|
|
|
84
84
|
...(discovered.disabledAgents?.length ? { disabledAgents: discovered.disabledAgents } : {}),
|
|
85
85
|
};
|
|
86
86
|
}
|
|
87
|
-
const MAX_LISTED_AGENTS = 30;
|
|
87
|
+
export const MAX_LISTED_AGENTS = 30;
|
|
88
88
|
const MAX_LISTED_DESCRIPTION_CHARS = 80;
|
|
89
89
|
/** One line per agent the caller can launch instead, so a wrong name needs no separate list call. */
|
|
90
90
|
export function formatAvailableAgentLines(agents) {
|
|
@@ -95,7 +95,7 @@ export function formatAvailableAgentLines(agents) {
|
|
|
95
95
|
return `- ${agent.name} (${agent.source})${short ? ` — ${short}` : ""}`;
|
|
96
96
|
});
|
|
97
97
|
if (sorted.length > MAX_LISTED_AGENTS)
|
|
98
|
-
lines.push(`+${sorted.length - MAX_LISTED_AGENTS} more; {action:"list"}`);
|
|
98
|
+
lines.push(`+${sorted.length - MAX_LISTED_AGENTS} more; {action:"list", options:{search:"<term>"}}`);
|
|
99
99
|
return lines.length ? lines : ["- (none)"];
|
|
100
100
|
}
|
|
101
101
|
/** The closest agent name or alias when `name` looks like a typo of one. */
|
|
@@ -953,21 +953,24 @@ function readSubagentSettings(filePath) {
|
|
|
953
953
|
const subagentsObject = subagents;
|
|
954
954
|
let disableBuiltins;
|
|
955
955
|
if ("disableBuiltins" in subagentsObject) {
|
|
956
|
-
if (typeof subagentsObject.disableBuiltins === "boolean")
|
|
956
|
+
if (typeof subagentsObject.disableBuiltins === "boolean")
|
|
957
957
|
disableBuiltins = subagentsObject.disableBuiltins;
|
|
958
|
-
|
|
959
|
-
else {
|
|
958
|
+
else
|
|
960
959
|
throw new Error(`Subagent settings in '${filePath}' have invalid 'disableBuiltins'; expected a boolean.`);
|
|
961
|
-
}
|
|
962
960
|
}
|
|
963
961
|
let disableThinking;
|
|
964
962
|
if ("disableThinking" in subagentsObject) {
|
|
965
|
-
if (typeof subagentsObject.disableThinking === "boolean")
|
|
963
|
+
if (typeof subagentsObject.disableThinking === "boolean")
|
|
966
964
|
disableThinking = subagentsObject.disableThinking;
|
|
967
|
-
|
|
968
|
-
else {
|
|
965
|
+
else
|
|
969
966
|
throw new Error(`Subagent settings in '${filePath}' have invalid 'disableThinking'; expected a boolean.`);
|
|
970
|
-
|
|
967
|
+
}
|
|
968
|
+
let defaultInheritGlobalContext;
|
|
969
|
+
if ("defaultInheritGlobalContext" in subagentsObject) {
|
|
970
|
+
if (typeof subagentsObject.defaultInheritGlobalContext === "boolean")
|
|
971
|
+
defaultInheritGlobalContext = subagentsObject.defaultInheritGlobalContext;
|
|
972
|
+
else
|
|
973
|
+
throw new Error(`Subagent settings in '${filePath}' have invalid 'defaultInheritGlobalContext'; expected a boolean.`);
|
|
971
974
|
}
|
|
972
975
|
let defaultModel;
|
|
973
976
|
if ("defaultModel" in subagentsObject) {
|
|
@@ -1051,6 +1054,7 @@ function readSubagentSettings(filePath) {
|
|
|
1051
1054
|
...(maxThinking !== undefined ? { maxThinking } : {}),
|
|
1052
1055
|
...(defaultExtensions !== undefined ? { defaultExtensions } : {}),
|
|
1053
1056
|
...(defaultSubagentOnlyExtensions !== undefined ? { defaultSubagentOnlyExtensions } : {}),
|
|
1057
|
+
...(defaultInheritGlobalContext !== undefined ? { defaultInheritGlobalContext } : {}),
|
|
1054
1058
|
...(agentScanDirs !== undefined ? { agentScanDirs } : {}),
|
|
1055
1059
|
...(agentExcludeDirs !== undefined ? { agentExcludeDirs } : {}),
|
|
1056
1060
|
...(disableBuiltins !== undefined ? { disableBuiltins } : {}),
|
|
@@ -1189,8 +1193,27 @@ function applySubagentDefaultSubagentOnlyExtensions(agents, defaultSubagentOnlyE
|
|
|
1189
1193
|
return next;
|
|
1190
1194
|
});
|
|
1191
1195
|
}
|
|
1192
|
-
function
|
|
1193
|
-
|
|
1196
|
+
function resolveSubagentDefaultInheritGlobalContext(userSettings, projectSettings, projectSettingsPath) {
|
|
1197
|
+
if (projectSettingsPath && projectSettings.defaultInheritGlobalContext !== undefined)
|
|
1198
|
+
return projectSettings.defaultInheritGlobalContext;
|
|
1199
|
+
return userSettings.defaultInheritGlobalContext;
|
|
1200
|
+
}
|
|
1201
|
+
// The parsed field is a plain boolean, so only the frontmatter key tells an explicit `false` from an unset field.
|
|
1202
|
+
function applySubagentDefaultInheritGlobalContext(agents, defaultInheritGlobalContext) {
|
|
1203
|
+
if (!defaultInheritGlobalContext)
|
|
1204
|
+
return agents;
|
|
1205
|
+
return agents.map((agent) => {
|
|
1206
|
+
const frontmatterFields = agentFrontmatterFields.get(agent);
|
|
1207
|
+
if (agent.inheritGlobalContext || frontmatterFields?.has("inheritGlobalContext"))
|
|
1208
|
+
return agent;
|
|
1209
|
+
const next = { ...agent, inheritGlobalContext: true };
|
|
1210
|
+
if (frontmatterFields)
|
|
1211
|
+
agentFrontmatterFields.set(next, frontmatterFields);
|
|
1212
|
+
return next;
|
|
1213
|
+
});
|
|
1214
|
+
}
|
|
1215
|
+
function applySubagentDefaults(agents, defaultModel, defaultProvider, defaultThinking, defaultExtensions, defaultSubagentOnlyExtensions, defaultInheritGlobalContext) {
|
|
1216
|
+
return applySubagentDefaultInheritGlobalContext(applySubagentDefaultSubagentOnlyExtensions(applySubagentDefaultExtensions(applySubagentDefaultThinking(applySubagentDefaultModel(agents, defaultModel, defaultProvider), defaultThinking), defaultExtensions), defaultSubagentOnlyExtensions), defaultInheritGlobalContext);
|
|
1194
1217
|
}
|
|
1195
1218
|
function applyToolsOverride(target, toolsOverride) {
|
|
1196
1219
|
if (toolsOverride === "inherit") {
|
|
@@ -2550,7 +2573,8 @@ function configuredAgentsForScope(sources, scope, settingsScope = scope) {
|
|
|
2550
2573
|
const maxThinking = resolveSubagentMaxThinking(userSettings, projectSettings, sources.projectSettingsPath);
|
|
2551
2574
|
const defaultExtensions = resolveSubagentDefaultExtensions(userSettings, projectSettings, sources.projectSettingsPath);
|
|
2552
2575
|
const defaultSubagentOnlyExtensions = resolveSubagentDefaultSubagentOnlyExtensions(userSettings, projectSettings, sources.projectSettingsPath);
|
|
2553
|
-
const
|
|
2576
|
+
const defaultInheritGlobalContext = resolveSubagentDefaultInheritGlobalContext(userSettings, projectSettings, sources.projectSettingsPath);
|
|
2577
|
+
const applyDefaults = (agents) => applySubagentDefaults(agents, defaultModel, defaultProvider, defaultThinking, defaultExtensions, defaultSubagentOnlyExtensions, defaultInheritGlobalContext);
|
|
2554
2578
|
const builtin = applyBuiltinOverrides(applyDefaults(sources.builtinLoaded.agents), userSettings, projectSettings, sources.userSettingsPath, sources.projectSettingsPath);
|
|
2555
2579
|
const user = applyCustomAgentOverrides(applyDefaults(scope === "project" ? [] : sources.userLoaded.flatMap((loaded) => loaded.loaded.agents)), userSettings, projectSettings, sources.userSettingsPath, sources.projectSettingsPath);
|
|
2556
2580
|
const projectMap = new Map();
|
|
@@ -2706,12 +2730,13 @@ function discoverAgentsUncached(cwd, scope, preferredModelProvider, options = {}
|
|
|
2706
2730
|
const maxThinking = resolveSubagentMaxThinking(userSettings, projectSettings, projectSettingsPath);
|
|
2707
2731
|
const defaultExtensions = resolveSubagentDefaultExtensions(userSettings, projectSettings, projectSettingsPath);
|
|
2708
2732
|
const defaultSubagentOnlyExtensions = resolveSubagentDefaultSubagentOnlyExtensions(userSettings, projectSettings, projectSettingsPath);
|
|
2733
|
+
const defaultInheritGlobalContext = resolveSubagentDefaultInheritGlobalContext(userSettings, projectSettings, projectSettingsPath);
|
|
2709
2734
|
const modelScope = projectSettings.modelScope ?? userSettings.modelScope;
|
|
2710
2735
|
const packageSubagentPaths = collectPackageSubagentPaths(effectiveCwd, { includeUser: scope !== "project", includeProject: scope !== "user", globalNpmRoot: options.globalNpmRoot });
|
|
2711
2736
|
const isExcluded = agentExclusions(agentExclusionRoots(userSettingsPath, projectSettingsPath));
|
|
2712
2737
|
const directories = [reportAgentDefinitionDirectory("builtin", BUILTIN_AGENTS_DIR, BUILTIN_AGENT_DEFINITION_INSPECTION)];
|
|
2713
2738
|
const builtinLoaded = loadAgentsFromDefinitionFiles(BUILTIN_AGENT_DEFINITION_FILES, "builtin");
|
|
2714
|
-
const applyDefaults = (agents) => applySubagentDefaults(agents, defaultModel, defaultProvider, defaultThinking, defaultExtensions, defaultSubagentOnlyExtensions);
|
|
2739
|
+
const applyDefaults = (agents) => applySubagentDefaults(agents, defaultModel, defaultProvider, defaultThinking, defaultExtensions, defaultSubagentOnlyExtensions, defaultInheritGlobalContext);
|
|
2715
2740
|
const builtinAgents = applyBuiltinOverrides(applyDefaults(builtinLoaded.agents), userSettings, projectSettings, userSettingsPath, projectSettingsPath);
|
|
2716
2741
|
const userScanDirs = settingsAgentScanDirs(userSettings.agentScanDirs ?? [], isExcluded);
|
|
2717
2742
|
const projectScanDirs = settingsAgentScanDirs(projectSettings.agentScanDirs ?? [], isExcluded);
|
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;
|
package/src/api/preflight.js
CHANGED
|
@@ -225,6 +225,7 @@ export async function resolveSubagentLaunchContract(input) {
|
|
|
225
225
|
: resolveEffectiveSubagentModel(input.model, agent.model, input.parentModel, availableModels, preferredProvider, {
|
|
226
226
|
scope: modelScopes,
|
|
227
227
|
source: modelOrigin === "explicit" ? "explicit" : "inherited",
|
|
228
|
+
knownProviders: input.knownProviders,
|
|
228
229
|
});
|
|
229
230
|
const effectiveThinkingConfig = input.thinking !== undefined ? input.thinking : agent.thinking;
|
|
230
231
|
const thinkingCeiling = externalRunner ? undefined : intersectThinkingCeilings(discovered.maxThinking, input.thinkingCeiling, input.inheritedThinkingCeiling);
|
|
@@ -232,6 +233,7 @@ export async function resolveSubagentLaunchContract(input) {
|
|
|
232
233
|
scope: modelScopes,
|
|
233
234
|
primaryModelFromParent: modelOrigin === "inherited" || inheritsParentModel(input.model, agent.model, input.parentModel),
|
|
234
235
|
origin: modelOrigin,
|
|
236
|
+
knownProviders: input.knownProviders,
|
|
235
237
|
}).model, effectiveThinkingConfig, input.thinking !== undefined);
|
|
236
238
|
if (!externalRunner) {
|
|
237
239
|
try {
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import { type ExtensionConfig } from "../shared/types.ts";
|
|
2
2
|
export declare function resolveScheduledStoreRoot(value: string): string;
|
|
3
|
+
/**
|
|
4
|
+
* Resolve the optional global default runtime deadline from extension config
|
|
5
|
+
* (`config.timeoutMs`). Returns undefined for unset or invalid values so callers
|
|
6
|
+
* use no configured deadline. "Invalid" covers non-positive-integer values and
|
|
7
|
+
* values above the Node.js timer ceiling; an invalid value counts as unset, and
|
|
8
|
+
* above that ceiling a timer fires almost at once, expiring the run instead of
|
|
9
|
+
* running long.
|
|
10
|
+
*/
|
|
11
|
+
export declare function resolveConfigDefaultTimeoutMs(raw: unknown): number | undefined;
|
|
3
12
|
export declare function getConfigPath(): string;
|
|
4
13
|
export declare function saveConfig(config: ExtensionConfig, configPath?: string): void;
|
|
5
14
|
export declare function updateConfig(updater: (config: ExtensionConfig) => ExtensionConfig): ExtensionConfig;
|
package/src/extension/config.js
CHANGED
|
@@ -244,6 +244,19 @@ function validateConfig(config) {
|
|
|
244
244
|
validateOrcaProgressTabsConfig(config.orcaProgressTabs);
|
|
245
245
|
validateRunnerLaunchersConfig(config.runnerLaunchers);
|
|
246
246
|
}
|
|
247
|
+
/**
|
|
248
|
+
* Resolve the optional global default runtime deadline from extension config
|
|
249
|
+
* (`config.timeoutMs`). Returns undefined for unset or invalid values so callers
|
|
250
|
+
* use no configured deadline. "Invalid" covers non-positive-integer values and
|
|
251
|
+
* values above the Node.js timer ceiling; an invalid value counts as unset, and
|
|
252
|
+
* above that ceiling a timer fires almost at once, expiring the run instead of
|
|
253
|
+
* running long.
|
|
254
|
+
*/
|
|
255
|
+
export function resolveConfigDefaultTimeoutMs(raw) {
|
|
256
|
+
if (typeof raw !== "number" || !Number.isInteger(raw) || raw <= 0 || raw > 2_147_483_647)
|
|
257
|
+
return undefined;
|
|
258
|
+
return raw;
|
|
259
|
+
}
|
|
247
260
|
export function getConfigPath() {
|
|
248
261
|
return path.join(getAgentDir(), "extensions", "subagent", "config.json");
|
|
249
262
|
}
|
package/src/extension/index.js
CHANGED
|
@@ -57,9 +57,9 @@ import registerSubagentNotify from "../runs/background/notify.js";
|
|
|
57
57
|
import { createParentWake } from "../shared/parent-wake.js";
|
|
58
58
|
import { handleSubagentSteeringNotice } from "./steering-notices.js";
|
|
59
59
|
import { SUBAGENT_CHILD_ENV, SUBAGENT_PARENT_SESSION_ENV } from "../runs/shared/child-runtime-config.js";
|
|
60
|
-
import {
|
|
60
|
+
import { disposeChildSessionsForParent } from "../runs/shared/child-session.js";
|
|
61
61
|
import { resolveCurrentSubagentCapabilityCeiling } from "../runs/shared/capability-ceiling.js";
|
|
62
|
-
import { loadConfig, resolveAsyncByDefault, resolveScheduledStoreRoot } from "./config.js";
|
|
62
|
+
import { loadConfig, resolveAsyncByDefault, resolveConfigDefaultTimeoutMs, resolveScheduledStoreRoot } from "./config.js";
|
|
63
63
|
import { buildSubagentToolDescription, buildSubagentToolPromptMetadata } from "./tool-description.js";
|
|
64
64
|
import { formatWorkflowPreflightSummary, normalizeWorkflowPreflight } from "../workflows/workflow-preflight.js";
|
|
65
65
|
import { runtimeReplacedAbortReason } from "../workflows/workflow-reuse.js";
|
|
@@ -490,7 +490,7 @@ export default function registerSubagentExtension(pi) {
|
|
|
490
490
|
});
|
|
491
491
|
}
|
|
492
492
|
catch (error) {
|
|
493
|
-
|
|
493
|
+
reportSessionWarning(state, `Failed to clean retained async subagent state: ${error instanceof Error ? error.message : String(error)}`, "async-retention-cleanup");
|
|
494
494
|
}
|
|
495
495
|
}, ASYNC_RETENTION_DELAY_MS);
|
|
496
496
|
asyncRetentionTimer.unref?.();
|
|
@@ -756,8 +756,9 @@ export default function registerSubagentExtension(pi) {
|
|
|
756
756
|
// A headless host may dispose the session as soon as this turn settles, so hand
|
|
757
757
|
// finished results to Pi now; Pi runs the queued completion turn after agent_end.
|
|
758
758
|
// A failed drain rejects without this step so its deadline stays exact.
|
|
759
|
+
// The parent ended its turn to wait for the wake, so the drain lasts as long as a run may.
|
|
759
760
|
if (!ctx.hasUI)
|
|
760
|
-
await drainOutstandingWork({ state, events: pi.events, hasPendingSupervisorRequest: supervisorChannel.hasPendingRequests }).then(resultWatcher.deliverPendingResults);
|
|
761
|
+
await drainOutstandingWork({ state, events: pi.events, hasPendingSupervisorRequest: supervisorChannel.hasPendingRequests, timeoutMs: resolveConfigDefaultTimeoutMs(config.timeoutMs) }).then(resultWatcher.deliverPendingResults);
|
|
761
762
|
}
|
|
762
763
|
finally {
|
|
763
764
|
// Deliver notices after a failed drain without suppressing its rejection.
|
|
@@ -1196,13 +1197,15 @@ export default function registerSubagentExtension(pi) {
|
|
|
1196
1197
|
supervisorChannel.activateTransport();
|
|
1197
1198
|
});
|
|
1198
1199
|
pi.on("session_shutdown", async (event) => {
|
|
1200
|
+
// Captured first: runtimeEntry.cleanup() below clears state.parentSessionFile.
|
|
1201
|
+
const parentSessionFile = state.parentSessionFile ?? undefined;
|
|
1199
1202
|
sessionSwitchGuard.sessionShutdown(event);
|
|
1200
1203
|
cancelCompactionResume();
|
|
1201
1204
|
completionNotifier.sessionShutdown(event?.reason);
|
|
1202
1205
|
parentWake.sessionShutdown(event?.reason);
|
|
1203
1206
|
runtimeEntry.cleanup(event?.reason);
|
|
1204
1207
|
try {
|
|
1205
|
-
await
|
|
1208
|
+
await disposeChildSessionsForParent(parentSessionFile);
|
|
1206
1209
|
}
|
|
1207
1210
|
catch (error) {
|
|
1208
1211
|
console.error("Failed to dispose in-process child sessions:", error);
|
|
@@ -7,6 +7,7 @@ export declare const SubagentFlatParams: Type.TObject<{
|
|
|
7
7
|
extensionBindings: Type.TOptional<Type.TUnsafe<unknown>>;
|
|
8
8
|
action: Type.TOptional<Type.TString>;
|
|
9
9
|
capabilities: Type.TOptional<Type.TBoolean>;
|
|
10
|
+
search: Type.TOptional<Type.TString>;
|
|
10
11
|
name: Type.TOptional<Type.TString>;
|
|
11
12
|
id: Type.TOptional<Type.TString>;
|
|
12
13
|
runId: Type.TOptional<Type.TString>;
|
|
@@ -19,6 +20,7 @@ export declare const SubagentFlatParams: Type.TObject<{
|
|
|
19
20
|
supersession: Type.TOptional<Type.TUnsafe<unknown>>;
|
|
20
21
|
index: Type.TOptional<Type.TInteger>;
|
|
21
22
|
childId: Type.TOptional<Type.TString>;
|
|
23
|
+
drain: Type.TOptional<Type.TBoolean>;
|
|
22
24
|
toolCallId: Type.TOptional<Type.TString>;
|
|
23
25
|
view: Type.TOptional<Type.TString>;
|
|
24
26
|
lines: Type.TOptional<Type.TInteger>;
|
|
@@ -140,6 +142,7 @@ export declare const SUBAGENT_OPTION_KEYS: readonly string[];
|
|
|
140
142
|
export declare const SubagentOptionParams: Type.TObject<{
|
|
141
143
|
extensionBindings: Type.TOptional<Type.TUnsafe<unknown>>;
|
|
142
144
|
capabilities: Type.TOptional<Type.TBoolean>;
|
|
145
|
+
search: Type.TOptional<Type.TString>;
|
|
143
146
|
name: Type.TOptional<Type.TString>;
|
|
144
147
|
dir: Type.TOptional<Type.TString>;
|
|
145
148
|
handoffPath: Type.TOptional<Type.TString>;
|
|
@@ -150,6 +153,7 @@ export declare const SubagentOptionParams: Type.TObject<{
|
|
|
150
153
|
supersession: Type.TOptional<Type.TUnsafe<unknown>>;
|
|
151
154
|
index: Type.TOptional<Type.TInteger>;
|
|
152
155
|
childId: Type.TOptional<Type.TString>;
|
|
156
|
+
drain: Type.TOptional<Type.TBoolean>;
|
|
153
157
|
toolCallId: Type.TOptional<Type.TString>;
|
|
154
158
|
view: Type.TOptional<Type.TString>;
|
|
155
159
|
lines: Type.TOptional<Type.TInteger>;
|
package/src/extension/schemas.js
CHANGED
|
@@ -141,6 +141,7 @@ const SubagentParamProperties = {
|
|
|
141
141
|
description: "Management/control only; omit for execution. validate accepts workflow: true or a script path. Discover actions with {action:\"guide\",options:{topic:\"tool-reference\"}}."
|
|
142
142
|
})),
|
|
143
143
|
capabilities: Type.Optional(Type.Boolean({ description: "list: compact capability rows/details without system prompts." })),
|
|
144
|
+
search: Type.Optional(Type.String({ minLength: 1, description: "list: case-insensitive match on agent name, alias, or description." })),
|
|
144
145
|
name: Type.Optional(Type.String({ description: "schedule.create name." })),
|
|
145
146
|
id: Type.Optional(Type.String({
|
|
146
147
|
description: "Run id/prefix for status/control."
|
|
@@ -159,6 +160,7 @@ const SubagentParamProperties = {
|
|
|
159
160
|
supersession: Type.Optional(Type.Unsafe({ type: "object", additionalProperties: true, description: "lane.recordSupersession evidence; read guide tool-reference." })),
|
|
160
161
|
index: Type.Optional(Type.Integer({ minimum: 0, description: "Zero-based child/transcript index." })),
|
|
161
162
|
childId: Type.Optional(Type.String({ minLength: 1, maxLength: 256, description: "Child-scoped stop identity." })),
|
|
163
|
+
drain: Type.Optional(Type.Boolean({ description: "stop: a live async workflow starts no new children; started ones finish." })),
|
|
162
164
|
toolCallId: Type.Optional(Type.String({ description: "Command tool-call id." })),
|
|
163
165
|
view: Type.Optional(Type.String({
|
|
164
166
|
enum: ["fleet", "transcript"],
|
|
@@ -182,11 +182,28 @@ export function registerSubagentToolActivation(pi, options) {
|
|
|
182
182
|
},
|
|
183
183
|
};
|
|
184
184
|
registerPinnedTool(pi, loader);
|
|
185
|
-
// Decided at session start and tree navigation
|
|
185
|
+
// Decided at session start and tree navigation. Pi declares a session's first tools only with its first request, so a
|
|
186
|
+
// model switch before then decides again; later switches keep the session's tools.
|
|
186
187
|
let loaderSelected = true;
|
|
188
|
+
// The loader and subagent state the last decision left, until the first request (agent_start). A different live
|
|
189
|
+
// state is a choice made since, and stands.
|
|
190
|
+
let undeclared;
|
|
191
|
+
const activationState = () => [LOADER_NAME, SUBAGENT_NAME].map((name) => pi.getActiveTools().includes(name)).join();
|
|
187
192
|
const replyOwed = () => options.hasPendingSupervisorRequest?.() === true;
|
|
188
|
-
|
|
189
|
-
|
|
193
|
+
const decide = (ctx) => {
|
|
194
|
+
loaderSelected = applyRecordedSelection(pi, ctx, mode, replyOwed());
|
|
195
|
+
undeclared = Array.isArray(pi.getActiveTools()) ? activationState() : undefined;
|
|
196
|
+
};
|
|
197
|
+
pi.on("session_start", (_event, ctx) => decide(ctx));
|
|
198
|
+
pi.on("session_tree", (_event, ctx) => decide(ctx));
|
|
199
|
+
pi.on("agent_start", () => { undeclared = undefined; });
|
|
200
|
+
// Only while idle: a run being prepared or started may already have fixed its first tools.
|
|
201
|
+
pi.on("model_select", (_event, ctx) => {
|
|
202
|
+
if (mode === "auto" && ctx.isIdle() && undeclared === activationState() && loaderSelected !== addsToolsWithoutCheckpoint(ctx.model)
|
|
203
|
+
// SAFETY: as in applyRecordedSelection.
|
|
204
|
+
&& ctx.sessionManager.buildSessionContext().messages.length === 0)
|
|
205
|
+
decide(ctx);
|
|
206
|
+
});
|
|
190
207
|
pi.on("before_agent_start", (event) => {
|
|
191
208
|
const available = pi.getAllTools();
|
|
192
209
|
if (!Array.isArray(available) || !available.some((tool) => tool.name === LOADER_NAME))
|
|
@@ -5,7 +5,7 @@ import { type ClaudeCodeOverride } from "../shared/claude-code-adapter.ts";
|
|
|
5
5
|
import { type ChainStep } from "../../shared/settings.ts";
|
|
6
6
|
import { type RunnerStep } from "../shared/parallel-utils.ts";
|
|
7
7
|
import type { ContextMode } from "../shared/context-mode.ts";
|
|
8
|
-
import { type AvailableModelInfo, type ModelOrigin, type ParentModel } from "../shared/model-resolution.ts";
|
|
8
|
+
import { type AvailableModelInfo, type KnownProviders, type ModelOrigin, type ParentModel } from "../shared/model-resolution.ts";
|
|
9
9
|
import { type ModelScopeConfig } from "../shared/model-scope.ts";
|
|
10
10
|
import { type ThinkingLevel } from "../../shared/thinking-ceiling.ts";
|
|
11
11
|
import { buildWorkflowGraphSnapshot } from "../shared/workflow-graph.ts";
|
|
@@ -32,6 +32,7 @@ interface AsyncExecutionContext {
|
|
|
32
32
|
currentModelProvider?: string;
|
|
33
33
|
currentModel?: ParentModel;
|
|
34
34
|
scopedModelIds?: string[];
|
|
35
|
+
knownProviders?: KnownProviders;
|
|
35
36
|
/** Optional model-scope enforcement resolved from subagent settings. */
|
|
36
37
|
modelScope?: ModelScopeConfig;
|
|
37
38
|
modelResponseAliases?: Record<string, string[]>;
|
|
@@ -956,7 +956,7 @@ export function buildAsyncRunnerSteps(id, params) {
|
|
|
956
956
|
const modelScopes = resolveModelScopesForAgent(ctx.modelScope, a.name, ctx.currentModel, ctx.scopedModelIds);
|
|
957
957
|
const modelOrigin = resolveModelOrigin({ explicitModel: s.model, agentModel: a.model, parentModel: ctx.currentModel });
|
|
958
958
|
const primaryModelFromParent = modelOrigin === "inherited";
|
|
959
|
-
const primaryModel = externalRunner ? undefined : resolveEffectiveSubagentModel(s.model, a.model, ctx.currentModel, availableModels, a.modelProvider ?? ctx.currentModelProvider, { scope: modelScopes, source: modelOrigin === "explicit" ? "explicit" : "inherited" });
|
|
959
|
+
const primaryModel = externalRunner ? undefined : resolveEffectiveSubagentModel(s.model, a.model, ctx.currentModel, availableModels, a.modelProvider ?? ctx.currentModelProvider, { scope: modelScopes, source: modelOrigin === "explicit" ? "explicit" : "inherited", knownProviders: ctx.knownProviders });
|
|
960
960
|
const thinkingOverride = flatIndex === undefined ? undefined : thinkingOverridesByFlatIndex?.[flatIndex];
|
|
961
961
|
let claudeCodeOverride;
|
|
962
962
|
if (claudeCodeAdapter) {
|
|
@@ -998,6 +998,7 @@ export function buildAsyncRunnerSteps(id, params) {
|
|
|
998
998
|
scope: modelScopes,
|
|
999
999
|
primaryModelFromParent,
|
|
1000
1000
|
origin: modelOrigin,
|
|
1001
|
+
knownProviders: ctx.knownProviders,
|
|
1001
1002
|
});
|
|
1002
1003
|
requestedModel = modelEvidence.requestedModel;
|
|
1003
1004
|
selectedModel = applyThinkingSuffix(modelEvidence.model, effectiveThinking, thinkingOverride !== undefined);
|
|
@@ -1754,7 +1755,7 @@ export function executeAsyncSingle(id, params) {
|
|
|
1754
1755
|
try {
|
|
1755
1756
|
primaryModel = externalRunner ? undefined : modelOrigin === "inherited"
|
|
1756
1757
|
? params.modelOverride ?? (ctx.currentModel ? `${ctx.currentModel.provider}/${ctx.currentModel.id}` : undefined)
|
|
1757
|
-
: resolveSubagentModelOverride(params.modelOverride ?? agentConfig.model, ctx.currentModel, availableModels, ctx.currentModelProvider, { scope: modelScopes, source: modelOrigin === "explicit" ? "explicit" : "inherited" });
|
|
1758
|
+
: resolveSubagentModelOverride(params.modelOverride ?? agentConfig.model, ctx.currentModel, availableModels, ctx.currentModelProvider, { scope: modelScopes, source: modelOrigin === "explicit" ? "explicit" : "inherited", knownProviders: ctx.knownProviders });
|
|
1758
1759
|
}
|
|
1759
1760
|
catch (error) {
|
|
1760
1761
|
return formatAsyncStartError("single", error instanceof Error ? error.message : String(error));
|
|
@@ -1821,6 +1822,7 @@ export function executeAsyncSingle(id, params) {
|
|
|
1821
1822
|
scope: modelScopes,
|
|
1822
1823
|
primaryModelFromParent: modelOrigin === "inherited",
|
|
1823
1824
|
origin: modelOrigin,
|
|
1825
|
+
knownProviders: ctx.knownProviders,
|
|
1824
1826
|
});
|
|
1825
1827
|
requestedModel = modelEvidence.requestedModel;
|
|
1826
1828
|
selectedModel = applyThinkingSuffix(modelEvidence.model, effectiveThinking, params.thinkingOverride !== undefined);
|
|
@@ -20,6 +20,7 @@ import { validateIntercomBridgeConfig } from "../../intercom/intercom-bridge.js"
|
|
|
20
20
|
import { validateModelResponseAliases } from "../../shared/model-response-aliases.js";
|
|
21
21
|
import { readWorkflowLaunchRecord } from "../../workflows/workflow-launch-record.js";
|
|
22
22
|
import { recoveryDescriptorPath } from "../shared/run-launch-folder.js";
|
|
23
|
+
import { missingForkCopyNote } from "../../shared/artifacts.js";
|
|
23
24
|
function getErrorMessage(error) {
|
|
24
25
|
return error instanceof Error ? error.message : String(error);
|
|
25
26
|
}
|
|
@@ -499,7 +500,7 @@ function validateResumeSessionFile(runId, sessionFile) {
|
|
|
499
500
|
throw new Error(`Async run '${runId}' session file must be a .jsonl file: ${sessionFile}`);
|
|
500
501
|
const resolved = path.resolve(sessionFile);
|
|
501
502
|
if (!fs.existsSync(resolved))
|
|
502
|
-
throw new Error(`Async run '${runId}' session file does not exist: ${sessionFile}`);
|
|
503
|
+
throw new Error(`Async run '${runId}' session file does not exist: ${sessionFile}${missingForkCopyNote(resolved)}`);
|
|
503
504
|
return resolved;
|
|
504
505
|
}
|
|
505
506
|
function validateResumeCwd(runId, cwd) {
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import * as fs from "node:fs";
|
|
2
|
-
export declare const ASYNC_RETENTION_DAYS = 30;
|
|
3
2
|
export declare const ASYNC_RETENTION_BATCH_SIZE = 100;
|
|
4
3
|
export declare const ASYNC_RETENTION_DELAY_MS = 60000;
|
|
5
|
-
export declare const ASYNC_RETENTION_TOMBSTONE_GRACE_MS: number;
|
|
6
4
|
export declare const RESUMABLE_RETENTION_DAYS = 90;
|
|
7
5
|
export interface AsyncRetentionOptions {
|
|
8
6
|
asyncDirRoot: string;
|
|
@@ -12,10 +12,10 @@ import { ACTIVE_RUN_INDEX_DIR } from "./active-run-index.js";
|
|
|
12
12
|
import { encodeIndexSegment } from "./index-segment.js";
|
|
13
13
|
import { reconcileAsyncRun } from "./stale-run-reconciler.js";
|
|
14
14
|
import { recoveryDescriptorPath, runLaunchDir } from "../shared/run-launch-folder.js";
|
|
15
|
-
|
|
15
|
+
const ASYNC_RETENTION_DAYS = 30;
|
|
16
16
|
export const ASYNC_RETENTION_BATCH_SIZE = 100;
|
|
17
17
|
export const ASYNC_RETENTION_DELAY_MS = 60_000;
|
|
18
|
-
|
|
18
|
+
const ASYNC_RETENTION_TOMBSTONE_GRACE_MS = 24 * 60 * 60 * 1000;
|
|
19
19
|
// A run or result whose session file still exists can be resumed, so it is kept this long
|
|
20
20
|
// instead of ASYNC_RETENTION_DAYS. Session files outlive run dirs, so without a ceiling it is kept forever.
|
|
21
21
|
export const RESUMABLE_RETENTION_DAYS = 90;
|
|
@@ -296,9 +296,15 @@ async function computeProcessStartIdentity(pid) {
|
|
|
296
296
|
if (process.platform === "win32") {
|
|
297
297
|
// PowerShell takes ~0.5 s to start; a synchronous spawn would freeze the TUI.
|
|
298
298
|
const started = await new Promise((resolve) => {
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
299
|
+
// Node throws instead of calling back when the executable cannot be spawned at all (spawn UNKNOWN when policy blocks PowerShell).
|
|
300
|
+
try {
|
|
301
|
+
execFile("powershell.exe", ["-NoProfile", "-Command", `(Get-CimInstance Win32_Process -Filter "ProcessId=${pid}").CreationDate`], { encoding: "utf-8", windowsHide: true, timeout: 5_000 }, (error, stdout) => {
|
|
302
|
+
resolve(error ? "" : stdout.trim());
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
catch {
|
|
306
|
+
resolve("");
|
|
307
|
+
}
|
|
302
308
|
});
|
|
303
309
|
return started ? `win:${started}` : undefined;
|
|
304
310
|
}
|
|
@@ -244,6 +244,8 @@ function statusToSummary(asyncDir, status, nestedWarnings = [], nestedRoute) {
|
|
|
244
244
|
...(step.currentPath ? { currentPath: step.currentPath } : {}),
|
|
245
245
|
...(step.recentTools ? { recentTools: step.recentTools.map((tool) => ({ ...tool })) } : {}),
|
|
246
246
|
...(step.recentOutput ? { recentOutput: [...step.recentOutput] } : {}),
|
|
247
|
+
...(step.progressText ? { progressText: step.progressText } : {}),
|
|
248
|
+
...(step.progressUpdatedAt !== undefined ? { progressUpdatedAt: step.progressUpdatedAt } : {}),
|
|
247
249
|
...(step.turnCount !== undefined ? { turnCount: step.turnCount } : {}),
|
|
248
250
|
...(step.toolCount !== undefined ? { toolCount: step.toolCount } : {}),
|
|
249
251
|
...(step.steering ? { steering: step.steering } : {}),
|
|
@@ -554,6 +556,8 @@ function formatStepLine(step) {
|
|
|
554
556
|
parts.push(modelThinking);
|
|
555
557
|
if (step.durationMs !== undefined)
|
|
556
558
|
parts.push(formatDuration(step.durationMs));
|
|
559
|
+
if (step.progressText && step.status === "running")
|
|
560
|
+
parts.push(`progress: ${step.progressText}`);
|
|
557
561
|
if (step.tokens)
|
|
558
562
|
parts.push(`${formatTokens(step.tokens.total)} tok`);
|
|
559
563
|
if (step.lane)
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import type { Message } from "@earendil-works/pi-ai";
|
|
9
9
|
import type { ChildTranscriptWriter } from "../../shared/child-transcript.ts";
|
|
10
|
-
import type { EffectsProjection, RuntimeAcknowledgedChildExtensions, SubagentOutputState, ToolBudgetState, Usage } from "../../shared/types.ts";
|
|
10
|
+
import type { EffectsProjection, RuntimeAcknowledgedChildExtensions, SteeringFailureKind, SubagentOutputState, ToolBudgetState, Usage } from "../../shared/types.ts";
|
|
11
11
|
import { type ChildWatchdogConfig, type ChildWatchdogStateSnapshot, type ChildWatchdogStatusEvent } from "../../watchdog/child-status.ts";
|
|
12
12
|
import { type InProcessChildLaunch } from "../shared/child-launch.ts";
|
|
13
13
|
import { type ChildSessionFactory } from "../shared/child-session.ts";
|
|
@@ -44,6 +44,7 @@ export interface ChildEvent {
|
|
|
44
44
|
}
|
|
45
45
|
export interface SteerDelivery {
|
|
46
46
|
state: "delivered" | "queued" | "failed";
|
|
47
|
+
failureKind?: SteeringFailureKind;
|
|
47
48
|
deliveryStatus?: SteerDeliveryStatus;
|
|
48
49
|
message: string;
|
|
49
50
|
}
|
|
@@ -73,7 +74,6 @@ export interface RunChildSessionInput {
|
|
|
73
74
|
onContextWindow?: (contextWindow: number) => void;
|
|
74
75
|
transcriptWriter?: ChildTranscriptWriter;
|
|
75
76
|
toolTimeoutMs?: number;
|
|
76
|
-
runDeadlineAt?: number;
|
|
77
77
|
expectedModelForVerification?: string;
|
|
78
78
|
modelVerificationRegistry?: Array<{
|
|
79
79
|
provider: string;
|
|
@@ -297,9 +297,6 @@ export function runChildSession(input) {
|
|
|
297
297
|
const timeoutForTool = effectiveToolTimeoutMs(event.toolName, input.toolTimeoutMs);
|
|
298
298
|
if (timeoutForTool === undefined)
|
|
299
299
|
return;
|
|
300
|
-
const runRemaining = input.runDeadlineAt === undefined ? undefined : Math.max(0, input.runDeadlineAt - Date.now());
|
|
301
|
-
if (runRemaining !== undefined && timeoutForTool >= runRemaining)
|
|
302
|
-
return;
|
|
303
300
|
const key = toolTimeoutCallKey(event, ++toolTimeoutSequence);
|
|
304
301
|
const toolName = event.toolName;
|
|
305
302
|
const timer = setTimeout(() => {
|
|
@@ -482,7 +479,7 @@ export function runChildSession(input) {
|
|
|
482
479
|
};
|
|
483
480
|
const failUnconsumedSteers = () => {
|
|
484
481
|
for (const entry of acceptedSteers.splice(0)) {
|
|
485
|
-
input.onSteerOutcome?.(entry.request, { state: "failed", message: unconsumedSteerReason(entry.request.mode) });
|
|
482
|
+
input.onSteerOutcome?.(entry.request, { state: "failed", failureKind: "unconsumed", message: unconsumedSteerReason(entry.request.mode) });
|
|
486
483
|
}
|
|
487
484
|
};
|
|
488
485
|
/** The child run ended (or was forced to end); fold in the outcome once the child's shutdown work is done. */
|
|
@@ -603,14 +600,14 @@ export function runChildSession(input) {
|
|
|
603
600
|
const steer = created.steer.bind(created);
|
|
604
601
|
const followUp = created.followUp.bind(created);
|
|
605
602
|
created.steer = async (text) => {
|
|
603
|
+
await steer(text);
|
|
606
604
|
if (cleanTerminalAssistantStopReceived || agentSettledReceived)
|
|
607
605
|
queuedDrainHold = true;
|
|
608
|
-
return steer(text);
|
|
609
606
|
};
|
|
610
607
|
created.followUp = async (text) => {
|
|
608
|
+
await followUp(text);
|
|
611
609
|
if (cleanTerminalAssistantStopReceived || agentSettledReceived)
|
|
612
610
|
queuedDrainHold = true;
|
|
613
|
-
return followUp(text);
|
|
614
611
|
};
|
|
615
612
|
unsubscribe = created.subscribe(processEvent);
|
|
616
613
|
input.registerWatchdogStatus?.((event) => processEvent(event));
|
|
@@ -634,7 +631,7 @@ export function runChildSession(input) {
|
|
|
634
631
|
const index = acceptedSteers.indexOf(accepted);
|
|
635
632
|
if (index >= 0)
|
|
636
633
|
acceptedSteers.splice(index, 1);
|
|
637
|
-
return { state: "failed", message: steerError instanceof Error ? steerError.message : String(steerError) };
|
|
634
|
+
return { state: "failed", failureKind: "rejected", message: steerError instanceof Error ? steerError.message : String(steerError) };
|
|
638
635
|
}
|
|
639
636
|
return queued;
|
|
640
637
|
});
|
|
@@ -33,6 +33,7 @@ const CHORD_PEER_ALIASES = [
|
|
|
33
33
|
{ specifier: "@earendil-works/chord", pkg: "@earendil-works/chord", subpath: "." },
|
|
34
34
|
{ specifier: "@earendil-works/chord/context", pkg: "@earendil-works/chord", subpath: "./context" },
|
|
35
35
|
];
|
|
36
|
+
const SCHEMA_PACKAGE = "@earendil-works/pi-schema";
|
|
36
37
|
function readManifest(packageDir) {
|
|
37
38
|
try {
|
|
38
39
|
return JSON.parse(fs.readFileSync(path.join(packageDir, "package.json"), "utf-8"));
|
|
@@ -155,5 +156,19 @@ export function resolveHostPeerAliases(piPackageRoot) {
|
|
|
155
156
|
else if (pkg !== CHORD_PACKAGE || chordRequired)
|
|
156
157
|
missing.push(specifier);
|
|
157
158
|
}
|
|
159
|
+
// Pi 1.5+ pi-ai imports pi-schema; without it a child dies after its launch was accepted. pi-ai's
|
|
160
|
+
// own import already reaches the right copy, so this is only a presence check, never an alias:
|
|
161
|
+
// an alias would also redirect extensions that ship their own copy.
|
|
162
|
+
const piAiDir = findPeerPackageDir(piPackageRoot, "@earendil-works/pi-ai", hostManifest?.name);
|
|
163
|
+
const piAiManifest = piAiDir ? readManifest(piAiDir) : undefined;
|
|
164
|
+
if (piAiDir && piAiManifest && declaresDependency(piAiManifest, SCHEMA_PACKAGE)) {
|
|
165
|
+
// Resolve from pi-ai's real path, as Node does, so nested, hoisted and pnpm-sibling copies count.
|
|
166
|
+
const schemaDir = findPeerPackageDir(fs.realpathSync(piAiDir), SCHEMA_PACKAGE, undefined);
|
|
167
|
+
for (const subpath of [".", "./formats"]) {
|
|
168
|
+
const target = schemaDir ? resolvePackageSubpath(schemaDir, subpath) : undefined;
|
|
169
|
+
if (!target || !fs.existsSync(target))
|
|
170
|
+
missing.push(subpath === "." ? SCHEMA_PACKAGE : `${SCHEMA_PACKAGE}/formats`);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
158
173
|
return { aliases, missing };
|
|
159
174
|
}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import type { AsyncStatus, ResolvedToolBudget, SteerActionResult, SteeringRecoveryDescriptor, SteeringRequestStatus, SteeringStatus, SteeringTargetState, SteeringTargetStatus } from "../../shared/types.ts";
|
|
2
2
|
import type { SteerDeliveryMode } from "./control-channel.ts";
|
|
3
|
-
export declare const MAX_STEERING_REQUESTS = 20;
|
|
4
|
-
export declare const STEERING_MESSAGE_PREVIEW_LIMIT = 160;
|
|
5
3
|
export declare function steeringMessagePreview(message: string): string;
|
|
6
4
|
/** FIFO match of one accepted steer to an emitted user message; equal text claims the oldest entry. */
|
|
7
5
|
export declare function takeMatchingAcceptedSteer<T extends {
|
|
@@ -17,16 +15,10 @@ export declare function recordSteeringRequest(status: SteeringStatus, input: {
|
|
|
17
15
|
requestedAt: number;
|
|
18
16
|
source?: string;
|
|
19
17
|
message: string;
|
|
20
|
-
targets: Array<
|
|
21
|
-
index: number;
|
|
22
|
-
state: SteeringTargetState;
|
|
23
|
-
reason?: string;
|
|
24
|
-
}>;
|
|
18
|
+
targets: Array<Pick<SteeringTargetStatus, "index" | "state" | "reason" | "failureKind">>;
|
|
25
19
|
}): SteeringRequestStatus;
|
|
26
|
-
export declare function updateSteeringTarget(status: SteeringStatus, requestId: string, index: number, state: SteeringTargetState, now: number, fields?: Pick<SteeringTargetStatus, "reason" | "replacementRunId">): SteeringTargetStatus | undefined;
|
|
27
|
-
export declare function findSteeringRequest(status: SteeringStatus, requestId: string): SteeringRequestStatus | undefined;
|
|
20
|
+
export declare function updateSteeringTarget(status: SteeringStatus, requestId: string, index: number, state: SteeringTargetState, now: number, fields?: Pick<SteeringTargetStatus, "reason" | "replacementRunId" | "failureKind">): SteeringTargetStatus | undefined;
|
|
28
21
|
export declare function actionResultFromSteeringStatus(status: SteeringStatus, sourceRunId: string, requestId: string, replacementRunId?: string): SteerActionResult | undefined;
|
|
29
|
-
export declare function steeringActionIsTerminal(result: SteerActionResult | undefined): boolean;
|
|
30
22
|
export declare function terminalSteeringNoticeState(status: SteeringStatus, requestId: string): "failed" | "partial" | undefined;
|
|
31
23
|
export declare function claimSteeringRecovery(asyncDir: string, input: {
|
|
32
24
|
requestId: string;
|
|
@@ -36,7 +28,6 @@ export declare function claimSteeringRecovery(asyncDir: string, input: {
|
|
|
36
28
|
claimPath: string;
|
|
37
29
|
markerPath: string;
|
|
38
30
|
};
|
|
39
|
-
export declare function readSteeringStatus(asyncDir: string): SteeringStatus | undefined;
|
|
40
31
|
export declare function remainingSteeringRecoveryLimits(descriptor: Pick<SteeringRecoveryDescriptor, "absoluteDeadlineAt" | "initialToolBudget">, status: Pick<AsyncStatus, "toolBudget" | "toolCount">, now?: number): {
|
|
41
32
|
timeoutMs?: number;
|
|
42
33
|
absoluteDeadlineAt?: number;
|