@xzzpig/pi-subagents 0.14.0 → 0.15.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 +233 -0
- package/README.md +6 -5
- package/agents/evidence-auditor.md +34 -0
- package/agents/researcher.md +23 -13
- package/agents/reviewer.md +3 -2
- package/docs/agents.md +56 -15
- package/docs/configuration.md +92 -14
- package/docs/extension-api.md +132 -19
- package/docs/missions.md +10 -2
- package/docs/models.md +11 -22
- package/docs/observability.md +63 -11
- package/docs/standalone-background.md +59 -0
- package/docs/tool-reference.md +42 -23
- package/docs/watchdog.md +39 -10
- package/docs/workflows.md +58 -19
- package/index.ts +5 -2
- package/inspector-runner.mjs +2 -2
- package/node_modules/@xzzpig/pi-components/dist/src/transcript.d.ts +13 -3
- package/node_modules/@xzzpig/pi-components/dist/src/transcript.js +18 -6
- package/node_modules/@xzzpig/pi-components/src/transcript.ts +26 -6
- package/package.json +9 -4
- package/prompts/parallel-review.md +1 -1
- package/runner-peer-loader.mjs +24 -0
- package/runner-peer-preload.mjs +36 -0
- package/skills/pi-subagents/SKILL.md +34 -22
- package/skills/pi-subagents/references/constraints-and-recipes.md +3 -2
- package/skills/pi-subagents/references/execution-controls.md +27 -8
- package/skills/pi-subagents/references/management-authoring-rpc.md +2 -2
- package/skills/pi-subagents/references/multi-lane-orchestration.md +3 -1
- package/skills/pi-subagents/references/prompting-and-roles.md +17 -13
- package/skills/pi-subagents/references/review-and-validation.md +3 -3
- package/src/agents/advertised-agent-prompt.ts +94 -0
- package/src/agents/agent-management.ts +71 -59
- package/src/agents/agent-serializer.ts +6 -3
- package/src/agents/agents.ts +198 -72
- package/src/agents/builtin-names.ts +1 -0
- package/src/agents/chain-serializer.ts +5 -0
- package/src/agents/runtime-agent-registry.ts +7 -6
- package/src/api/delegation.ts +4 -0
- package/src/api/preflight.ts +110 -71
- package/src/api/required-child-extensions.ts +6 -0
- package/src/api/shared-types.ts +3 -1
- package/src/api/workflow-resources.ts +6 -0
- package/src/extension/config.ts +14 -37
- package/src/extension/fanout-child.ts +68 -5
- package/src/extension/herdr-pi-bridge.ts +164 -0
- package/src/extension/index.ts +141 -51
- package/src/extension/public-execution.ts +7 -6
- package/src/extension/rpc.ts +8 -21
- package/src/extension/schemas.ts +86 -84
- package/src/extension/tool-description.ts +32 -79
- package/src/inspectors/actions.ts +148 -0
- package/src/inspectors/ghostty/actions.ts +74 -0
- package/src/inspectors/ghostty/plugin.ts +17 -0
- package/src/inspectors/herdr/actions.ts +99 -179
- package/src/inspectors/herdr/plugin.ts +20 -0
- package/src/inspectors/herdr/project-panes.ts +4 -1
- package/src/inspectors/{herdr/inspector-runner.ts → inspector-runner.ts} +12 -12
- package/src/inspectors/plugins.ts +8 -0
- package/src/inspectors/{herdr/session-roots-codec.ts → session-roots-codec.ts} +3 -14
- package/src/inspectors/types.ts +51 -0
- package/src/integrations/pi-web-session-liveness.ts +73 -0
- package/src/intercom/intercom-bridge.ts +50 -8
- package/src/intercom/native-supervisor-channel.ts +142 -115
- package/src/intercom/supervisor-ui.ts +3 -2
- package/src/missions/workflow-state.ts +37 -16
- package/src/policy/authority.ts +4 -0
- package/src/profiles/profiles.ts +12 -6
- package/src/runs/background/active-async-capacity.ts +22 -18
- package/src/runs/background/active-run-index.ts +17 -1
- package/src/runs/background/async-execution.ts +359 -176
- package/src/runs/background/async-job-tracker.ts +41 -7
- package/src/runs/background/async-resume.ts +19 -12
- package/src/runs/background/async-retention.ts +20 -0
- package/src/runs/background/async-status-snapshot.ts +10 -12
- package/src/runs/background/async-status.ts +32 -13
- package/src/runs/background/auto-drain.ts +59 -35
- package/src/runs/background/binary-bootstrap.ts +38 -0
- package/src/runs/background/chain-append.ts +1 -1
- package/src/runs/background/chain-root-attachment.ts +22 -33
- package/src/runs/background/control-channel.ts +78 -44
- package/src/runs/background/fleet-view.ts +30 -2
- package/src/runs/background/notify.ts +193 -19
- package/src/runs/background/owned-process-tree.ts +35 -8
- package/src/runs/background/process-terminal.ts +23 -23
- package/src/runs/background/result-files.ts +8 -4
- package/src/runs/background/result-watcher.ts +19 -2
- package/src/runs/background/retained-nested-route-tracker.ts +96 -0
- package/src/runs/background/run-child-session.ts +118 -41
- package/src/runs/background/run-status.ts +78 -5
- package/src/runs/background/runner-aliases.ts +22 -5
- package/src/runs/background/runner-child-launch.ts +93 -0
- package/src/runs/background/runner-child-sessions.ts +5 -4
- package/src/runs/background/runner-http-dispatcher.ts +119 -0
- package/src/runs/background/scheduled-runs.ts +51 -18
- package/src/runs/background/stale-run-reconciler.ts +38 -12
- package/src/runs/background/steering.ts +20 -2
- package/src/runs/background/subagent-runner.ts +766 -432
- package/src/runs/background/subagent-wait.ts +179 -28
- package/src/runs/background/wait-completions.ts +79 -27
- package/src/runs/background/wait-subscriptions.ts +9 -3
- package/src/runs/background/wait-tool.ts +5 -3
- package/src/runs/foreground/async-steering-action.ts +37 -7
- package/src/runs/foreground/async-stop-action.ts +93 -3
- package/src/runs/foreground/execution.ts +174 -194
- package/src/runs/foreground/foreground-history.ts +5 -2
- package/src/runs/foreground/prompt-audit.ts +12 -6
- package/src/runs/foreground/subagent-executor.ts +896 -397
- package/src/runs/foreground/workflow-detach-reconcile.ts +10 -5
- package/src/runs/foreground/workflow-foreground-steering.ts +57 -2
- package/src/runs/shared/acceptance.ts +54 -14
- package/src/runs/shared/agent-contract.ts +1 -1
- package/src/runs/shared/async-status-projection.ts +172 -78
- package/src/runs/shared/capability-ceiling.ts +2 -0
- package/src/runs/shared/child-hooks.ts +167 -3
- package/src/runs/shared/child-launch-plan.ts +15 -3
- package/src/runs/shared/child-launch.ts +44 -16
- package/src/runs/shared/child-lifecycle.ts +6 -3
- package/src/runs/shared/child-runtime-config.ts +8 -1
- package/src/runs/shared/child-session.ts +130 -24
- package/src/runs/shared/child-tool-plan.ts +145 -14
- package/src/runs/shared/completion-evidence.ts +2 -2
- package/src/runs/shared/completion-guard.ts +6 -3
- package/src/runs/shared/dynamic-fanout.ts +2 -2
- package/src/runs/shared/effective-system-prompt.ts +33 -0
- package/src/runs/shared/external-cli-contract.ts +11 -1
- package/src/runs/shared/external-cli-preflight.ts +6 -2
- package/src/runs/shared/external-cli-runner.ts +9 -7
- package/src/runs/shared/herdr-connection.ts +134 -0
- package/src/runs/shared/herdr-external-adapters.ts +169 -0
- package/src/runs/shared/herdr-machine.ts +279 -0
- package/src/runs/shared/herdr-pi-protocol.ts +59 -0
- package/src/runs/shared/herdr-placed-run.ts +263 -0
- package/src/runs/shared/host-step-status.ts +11 -11
- package/src/runs/shared/llm-intent-arbiter.ts +40 -21
- package/src/runs/shared/model-resolution-diagnostic.ts +76 -0
- package/src/runs/shared/{model-fallback.ts → model-resolution.ts} +34 -218
- package/src/runs/shared/model-scope.ts +1 -1
- package/src/runs/shared/nested-events.ts +19 -10
- package/src/runs/shared/orca-progress-tabs.ts +7 -1
- package/src/runs/shared/parallel-handoff.ts +57 -12
- package/src/runs/shared/parallel-utils.ts +10 -4
- package/src/runs/shared/pi-spawn.ts +10 -0
- package/src/runs/shared/readonly-drain-observation.ts +42 -0
- package/src/runs/shared/run-fanout-budget.ts +8 -8
- package/src/runs/shared/runtime-acknowledged-extensions.ts +3 -3
- package/src/runs/shared/subagent-prompt-runtime.ts +23 -5
- package/src/runs/shared/task-intent.ts +46 -13
- package/src/runs/shared/workflow-async-child-guidance.ts +18 -0
- package/src/runs/shared/worktree-cleanup-plan.ts +6 -3
- package/src/runs/shared/worktree-setup-command.ts +213 -0
- package/src/runs/shared/worktree.ts +437 -214
- package/src/shared/child-cache-retention.ts +43 -0
- package/src/shared/fork-context.ts +15 -72
- package/src/shared/launch-contract.ts +70 -8
- package/src/shared/model-response-aliases.ts +13 -0
- package/src/shared/opencode-session-headers.ts +30 -0
- package/src/shared/pruned-fork.ts +1 -1
- package/src/shared/required-child-extensions.ts +81 -0
- package/src/shared/settings.ts +5 -2
- package/src/shared/shortcuts.ts +0 -4
- package/src/shared/types.ts +163 -90
- package/src/shared/utils.ts +10 -2
- package/src/shared/watch-strategy.ts +2 -0
- package/src/shared/workflow-child-permit.ts +18 -13
- package/src/slash/delegation-adapters.ts +3 -1
- package/src/slash/delegation-request.ts +14 -0
- package/src/slash/slash-commands.ts +2 -7
- package/src/slash/subagents-admin.ts +31 -14
- package/src/tui/fleet-status.ts +165 -20
- package/src/tui/fleet.ts +30 -19
- package/src/tui/render.ts +210 -50
- package/src/watchdog/child-status.ts +28 -28
- package/src/watchdog/lsp-diagnostics.ts +1 -1
- package/src/watchdog/model-selection.ts +21 -1
- package/src/watchdog/permission-arbiter.ts +5 -2
- package/src/watchdog/register-child.ts +10 -2
- package/src/watchdog/register-main.ts +39 -35
- package/src/watchdog/render.ts +1 -1
- package/src/watchdog/review.ts +122 -74
- package/src/watchdog/rules.ts +1 -1
- package/src/watchdog/runtime.ts +100 -27
- package/src/watchdog/scope.ts +1 -1
- package/src/watchdog/settings.ts +3 -0
- package/src/watchdog/tool-actions.ts +13 -12
- package/src/watchdog/turn-delta.ts +23 -0
- package/src/watchdog/types.ts +5 -3
- package/src/watchdog/warning-format.ts +1 -1
- package/src/workflows/chat-progress.ts +3 -3
- package/src/workflows/scripted-workflow.ts +349 -26
- package/src/workflows/workflow-checklist.ts +17 -20
- package/src/workflows/workflow-child-summary.ts +57 -8
- package/src/workflows/workflow-preflight.ts +19 -19
- package/src/workflows/workflow-receipt.ts +24 -6
- package/src/workflows/workflow-resources.ts +108 -22
- package/src/workflows/workflow-settlement.ts +3 -0
- package/src/runs/shared/model-exclusions.ts +0 -373
- /package/src/inspectors/{herdr/shell-command.ts → shell-command.ts} +0 -0
|
@@ -22,6 +22,10 @@ function parseStepBody(agent: string, sectionBody: string): ChainStepConfig {
|
|
|
22
22
|
const key = keyValue.trim().toLowerCase();
|
|
23
23
|
const rawValue = rawValueValue.trim();
|
|
24
24
|
|
|
25
|
+
if (key === "machine") {
|
|
26
|
+
if (rawValue) step.machine = rawValue;
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
25
29
|
if (key === "output") {
|
|
26
30
|
if (rawValue === "false") step.output = false;
|
|
27
31
|
else if (rawValue) step.output = rawValue;
|
|
@@ -257,6 +261,7 @@ export function serializeChain(config: ChainConfig): string {
|
|
|
257
261
|
for (let i = 0; i < config.steps.length; i++) {
|
|
258
262
|
const step = config.steps[i]!;
|
|
259
263
|
lines.push(`## ${step.agent}`);
|
|
264
|
+
if (step.machine) lines.push(`machine: ${step.machine}`);
|
|
260
265
|
if (step.output === false) lines.push("output: false");
|
|
261
266
|
else if (step.output) lines.push(`output: ${step.output}`);
|
|
262
267
|
if (step.phase) lines.push(`phase: ${step.phase}`);
|
|
@@ -26,7 +26,6 @@ export interface RuntimeAgentDefinition {
|
|
|
26
26
|
allowNestedSubagents?: boolean;
|
|
27
27
|
mcpDirectTools?: readonly string[];
|
|
28
28
|
model?: string;
|
|
29
|
-
fallbackModels?: readonly string[];
|
|
30
29
|
thinking?: string | false;
|
|
31
30
|
systemPromptMode?: "append" | "replace";
|
|
32
31
|
inheritProjectContext?: boolean;
|
|
@@ -39,6 +38,7 @@ export interface RuntimeAgentDefinition {
|
|
|
39
38
|
defaultAcceptance?: AcceptanceInput;
|
|
40
39
|
acceptanceRole?: AcceptanceRole;
|
|
41
40
|
runner?: AgentRunnerConfig;
|
|
41
|
+
machine?: string;
|
|
42
42
|
skills?: readonly string[];
|
|
43
43
|
skillPath?: readonly string[];
|
|
44
44
|
extensions?: readonly string[];
|
|
@@ -204,9 +204,9 @@ function validateDefinition(value: unknown): RuntimeAgentDefinition {
|
|
|
204
204
|
if (!value || typeof value !== "object" || Array.isArray(value)) throw new Error("Runtime agent definition must be an object.");
|
|
205
205
|
const definition = value as Record<string, unknown>;
|
|
206
206
|
const supported = new Set([
|
|
207
|
-
"description", "systemPrompt", "aliases", "tools", "excludeTools", "allowNestedSubagents", "mcpDirectTools", "model", "
|
|
207
|
+
"description", "systemPrompt", "aliases", "tools", "excludeTools", "allowNestedSubagents", "mcpDirectTools", "model", "thinking",
|
|
208
208
|
"systemPromptMode", "inheritProjectContext", "inheritGlobalContext", "inheritSkills", "defaultContext", "defaultAsync", "defaultTimeoutMs",
|
|
209
|
-
"defaultToolTimeoutMs", "defaultAcceptance", "acceptanceRole", "runner", "skills", "skillPath",
|
|
209
|
+
"defaultToolTimeoutMs", "defaultAcceptance", "acceptanceRole", "runner", "machine", "skills", "skillPath",
|
|
210
210
|
"extensions", "subagentOnlyExtensions", "mutationTools", "output", "outputMode", "defaultReads", "defaultProgress", "injectToContext", "interactive",
|
|
211
211
|
"maxSubagentDepth", "completionGuard", "toolBudget", "sandbox", "permissionProfile", "permissions",
|
|
212
212
|
]);
|
|
@@ -228,7 +228,7 @@ function validateDefinition(value: unknown): RuntimeAgentDefinition {
|
|
|
228
228
|
const allowNestedSubagents = validateBoolean(definition.allowNestedSubagents, "Runtime agent definition allowNestedSubagents");
|
|
229
229
|
const mcpDirectTools = validateStringList(definition.mcpDirectTools, "Runtime agent definition mcpDirectTools");
|
|
230
230
|
const model = validateOptionalString(definition.model, "Runtime agent definition model");
|
|
231
|
-
|
|
231
|
+
if ((definition as Record<string, unknown>).fallbackModels !== undefined) throw new Error("Runtime agent definition fallbackModels was removed; configure one model instead.");
|
|
232
232
|
const inheritProjectContext = validateBoolean(definition.inheritProjectContext, "Runtime agent definition inheritProjectContext");
|
|
233
233
|
const inheritGlobalContext = validateBoolean(definition.inheritGlobalContext, "Runtime agent definition inheritGlobalContext");
|
|
234
234
|
const inheritSkills = validateBoolean(definition.inheritSkills, "Runtime agent definition inheritSkills");
|
|
@@ -242,6 +242,7 @@ function validateDefinition(value: unknown): RuntimeAgentDefinition {
|
|
|
242
242
|
const extensions = validateStringList(definition.extensions, "Runtime agent definition extensions");
|
|
243
243
|
const subagentOnlyExtensions = validateStringList(definition.subagentOnlyExtensions, "Runtime agent definition subagentOnlyExtensions");
|
|
244
244
|
const mutationTools = validateStringList(definition.mutationTools, "Runtime agent definition mutationTools");
|
|
245
|
+
const machine = validateOptionalString(definition.machine, "Runtime agent definition machine");
|
|
245
246
|
const output = validateOptionalString(definition.output, "Runtime agent definition output");
|
|
246
247
|
const defaultReads = validateStringList(definition.defaultReads, "Runtime agent definition defaultReads");
|
|
247
248
|
const defaultProgress = validateBoolean(definition.defaultProgress, "Runtime agent definition defaultProgress");
|
|
@@ -272,7 +273,6 @@ function validateDefinition(value: unknown): RuntimeAgentDefinition {
|
|
|
272
273
|
...(allowNestedSubagents !== undefined ? { allowNestedSubagents } : {}),
|
|
273
274
|
...(mcpDirectTools ? { mcpDirectTools } : {}),
|
|
274
275
|
...(model ? { model } : {}),
|
|
275
|
-
...(fallbackModels ? { fallbackModels } : {}),
|
|
276
276
|
...(thinking !== undefined ? { thinking: thinking as string | false } : {}),
|
|
277
277
|
...(systemPromptMode !== undefined ? { systemPromptMode: systemPromptMode as "append" | "replace" } : {}),
|
|
278
278
|
...(inheritProjectContext !== undefined ? { inheritProjectContext } : {}),
|
|
@@ -290,6 +290,7 @@ function validateDefinition(value: unknown): RuntimeAgentDefinition {
|
|
|
290
290
|
...(extensions ? { extensions } : {}),
|
|
291
291
|
...(subagentOnlyExtensions ? { subagentOnlyExtensions } : {}),
|
|
292
292
|
...(mutationTools ? { mutationTools } : {}),
|
|
293
|
+
...(machine ? { machine } : {}),
|
|
293
294
|
...(output ? { output } : {}),
|
|
294
295
|
...(outputMode !== undefined ? { outputMode: outputMode as OutputMode } : {}),
|
|
295
296
|
...(defaultReads ? { defaultReads } : {}),
|
|
@@ -355,7 +356,6 @@ function toAgentConfig(name: string, definition: RuntimeAgentDefinition): AgentC
|
|
|
355
356
|
...(definition.allowNestedSubagents !== undefined ? { allowNestedSubagents: definition.allowNestedSubagents } : {}),
|
|
356
357
|
...(definition.mcpDirectTools !== undefined ? { mcpDirectTools: [...definition.mcpDirectTools] } : {}),
|
|
357
358
|
...(definition.model !== undefined ? { model: definition.model } : {}),
|
|
358
|
-
...(definition.fallbackModels !== undefined ? { fallbackModels: [...definition.fallbackModels] } : {}),
|
|
359
359
|
...(definition.thinking !== undefined ? { thinking: definition.thinking } : {}),
|
|
360
360
|
systemPromptMode: definition.systemPromptMode ?? defaultSystemPromptMode(name),
|
|
361
361
|
inheritProjectContext: definition.inheritProjectContext ?? defaultInheritProjectContext(name),
|
|
@@ -375,6 +375,7 @@ function toAgentConfig(name: string, definition: RuntimeAgentDefinition): AgentC
|
|
|
375
375
|
...(definition.extensions !== undefined ? { extensions: [...definition.extensions] } : {}),
|
|
376
376
|
...(definition.subagentOnlyExtensions !== undefined ? { subagentOnlyExtensions: [...definition.subagentOnlyExtensions] } : {}),
|
|
377
377
|
...(definition.mutationTools !== undefined ? { mutationTools: [...definition.mutationTools] } : {}),
|
|
378
|
+
...(definition.machine !== undefined ? { machine: definition.machine } : {}),
|
|
378
379
|
...(definition.output !== undefined ? { output: definition.output } : {}),
|
|
379
380
|
...(definition.outputMode !== undefined ? { outputMode: definition.outputMode } : {}),
|
|
380
381
|
...(definition.defaultReads !== undefined ? { defaultReads: [...definition.defaultReads] } : {}),
|
package/src/api/delegation.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { IntercomBridgeConfig } from "../shared/types.ts";
|
|
2
|
+
|
|
1
3
|
// This is the established extension-to-extension transport. The structured
|
|
2
4
|
// delegation API intentionally reuses it instead of adding a second event
|
|
3
5
|
// protocol. Unstructured legacy direct payloads are rejected.
|
|
@@ -35,6 +37,8 @@ export interface SubagentDelegationRequest {
|
|
|
35
37
|
toolBudget?: SubagentDelegationToolBudget;
|
|
36
38
|
skill?: string | string[] | boolean;
|
|
37
39
|
artifacts?: boolean;
|
|
40
|
+
/** Per-launch bridge config; replaces the global `intercomBridge` config. Pass the same value to preflight to compare digests. */
|
|
41
|
+
intercomBridge?: IntercomBridgeConfig;
|
|
38
42
|
result: SubagentDelegationResultRequest;
|
|
39
43
|
}
|
|
40
44
|
|
package/src/api/preflight.ts
CHANGED
|
@@ -3,30 +3,37 @@ import * as path from "node:path";
|
|
|
3
3
|
import { fileURLToPath } from "node:url";
|
|
4
4
|
import { discoverAgentSnapshot, findBlockingAgentDiagnostic, formatUnknownAgentError, resolveAgentName, unknownAgentDiagnosticContext, type AgentConfig, type AgentDiscoveryAllResult, type AgentScope, type AgentSource } from "../agents/agents.ts";
|
|
5
5
|
import { resolveExecutionAgentScope } from "../agents/agent-scope.ts";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { buildModelCandidates, inheritsParentModel, resolveEffectiveSubagentModel, resolveModelOrigin, type AvailableModelInfo, type ParentModel } from "../runs/shared/model-fallback.ts";
|
|
6
|
+
import { normalizeSkillInput, resolveSkillsWithFallback } from "../agents/skills.ts";
|
|
7
|
+
import { inheritsParentModel, resolveEffectiveSubagentModel, resolveModelOrigin, resolveModelSelection, type AvailableModelInfo, type ParentModel } from "../runs/shared/model-resolution.ts";
|
|
9
8
|
import { resolveModelScopesForAgent } from "../runs/shared/model-scope.ts";
|
|
10
9
|
import { applyThinkingSuffix, resolvePiLaunchToolPlan, type PiLaunchToolPlan } from "../runs/shared/child-tool-plan.ts";
|
|
11
|
-
import {
|
|
10
|
+
import { buildEffectiveSystemPrompt } from "../runs/shared/effective-system-prompt.ts";
|
|
11
|
+
import { normalizeSingleOutputOverride, resolveSingleOutputPath } from "../runs/shared/single-output.ts";
|
|
12
12
|
import { getArtifactPaths, getArtifactsDir } from "../shared/artifacts.ts";
|
|
13
13
|
import { resolveEffectiveThinking } from "../shared/model-info.ts";
|
|
14
14
|
import { assertThinkingWithinCeiling, intersectThinkingCeilings, type ThinkingLevel } from "../shared/thinking-ceiling.ts";
|
|
15
|
-
import { SUBAGENT_LIFECYCLE_ARTIFACT_VERSION, type ArtifactDirPreference, type ArtifactPaths, type JsonSchemaObject, type OutputMode } from "../shared/types.ts";
|
|
15
|
+
import { SUBAGENT_LIFECYCLE_ARTIFACT_VERSION, type ArtifactDirPreference, type ArtifactPaths, type IntercomBridgeConfig, type IntercomBridgeMode, type JsonSchemaObject, type OutputMode } from "../shared/types.ts";
|
|
16
16
|
import { capabilityCeilingAgentRestrictionMessage, intersectSubagentCapabilityCeilings, type ResolvedSubagentCapabilityCeiling, type SubagentCapabilityAudit } from "../runs/shared/capability-ceiling.ts";
|
|
17
17
|
import { resolvePermissionRules } from "../runs/shared/permissions.ts";
|
|
18
18
|
import type { ResolvedMcpDirectToolSelection } from "../runs/shared/mcp-direct-tool-allowlist.ts";
|
|
19
19
|
import { resolveStepBehavior } from "../shared/settings.ts";
|
|
20
20
|
import { canPreferForkFromSnapshot, resolveSubagentLaunchContext } from "../shared/fork-context.ts";
|
|
21
21
|
import { loadConfig } from "../extension/config.ts";
|
|
22
|
-
import {
|
|
22
|
+
import { applyIntercomBridgeToAgent, resolveIntercomBridge, validateIntercomBridgeConfig } from "../intercom/intercom-bridge.ts";
|
|
23
|
+
import { AGENT_DEFINITION_PROJECTION_VERSION, resolveLaunchBinding, stableJsonDigest } from "../shared/launch-contract.ts";
|
|
23
24
|
import { DIRS, TEMP_ROOT_DIR } from "../shared/types.ts";
|
|
24
25
|
import { processTerminalCandidatePath, processTerminalPath } from "../runs/background/process-terminal.ts";
|
|
25
26
|
import { resultFilePath } from "../runs/background/result-files.ts";
|
|
26
27
|
import { nestedResultsPath } from "../runs/shared/nested-events.ts";
|
|
27
28
|
import { normalizeExtensionBindings, type ExtensionBindings } from "../runs/shared/extension-bindings.ts";
|
|
29
|
+
import { resolveRequiredChildExtensions } from "../shared/required-child-extensions.ts";
|
|
28
30
|
|
|
29
|
-
|
|
31
|
+
// v3: the contract reports the resolved Intercom bridge state and binds its
|
|
32
|
+
// prompt and tools into launchContractDigest, matching execution (#2127).
|
|
33
|
+
export const SUBAGENT_LAUNCH_CONTRACT_VERSION = 3 as const;
|
|
34
|
+
|
|
35
|
+
/** Stands in for the parent session target when the host does not supply one; only custom templates that name the session read it. */
|
|
36
|
+
const PREFLIGHT_ORCHESTRATOR_TARGET = "preflight";
|
|
30
37
|
|
|
31
38
|
export type SubagentLaunchContractReasonCode =
|
|
32
39
|
| "missing_agent"
|
|
@@ -41,7 +48,8 @@ export type SubagentLaunchContractReasonCode =
|
|
|
41
48
|
| "invalid_extension_bindings"
|
|
42
49
|
| "untrusted_project"
|
|
43
50
|
| "sandbox_unavailable"
|
|
44
|
-
| "permission_profile_unavailable"
|
|
51
|
+
| "permission_profile_unavailable"
|
|
52
|
+
| "invalid_intercom_bridge";
|
|
45
53
|
|
|
46
54
|
export type SubagentLaunchContractDiagnosticCode = SubagentLaunchContractReasonCode | "host_required" | "snapshot_warning" | "workspace_scope_authority";
|
|
47
55
|
|
|
@@ -68,14 +76,17 @@ export interface SubagentLaunchContractInput {
|
|
|
68
76
|
skill?: string | string[] | boolean;
|
|
69
77
|
output?: string | boolean;
|
|
70
78
|
outputMode?: OutputMode;
|
|
71
|
-
outputSchema?: JsonSchemaObject;
|
|
79
|
+
outputSchema?: JsonSchemaObject | false;
|
|
72
80
|
extensionBindings?: ExtensionBindings;
|
|
73
81
|
artifacts?: boolean;
|
|
74
82
|
artifactDir?: ArtifactDirPreference;
|
|
75
83
|
parentSessionFile?: string | null;
|
|
84
|
+
/** Parent session whose host-required child extension snapshot is preflighted. */
|
|
85
|
+
parentSessionId?: string;
|
|
76
86
|
/** Current parent leaf required before an implicit `defaultContext: fork` stays `fork`. */
|
|
77
87
|
parentLeafId?: string | null;
|
|
78
88
|
sessionRoot?: string;
|
|
89
|
+
/** Caller directory used as a root keyed by the child run id ("preflight" placeholder when runId is omitted). */
|
|
79
90
|
sessionDir?: string;
|
|
80
91
|
runId?: string;
|
|
81
92
|
/** Root run id supplied by a host when projecting nested async lifecycle paths. */
|
|
@@ -86,8 +97,23 @@ export interface SubagentLaunchContractInput {
|
|
|
86
97
|
projectTrusted?: boolean;
|
|
87
98
|
/** Exact trusted project cwd. When omitted, an affirmative trust assertion applies only to `cwd`. */
|
|
88
99
|
trustedProjectCwd?: string;
|
|
100
|
+
/** Builtin tool names the host runtime provides; used to intersect agent-declared tools. */
|
|
101
|
+
hostAvailableBuiltins?: readonly string[];
|
|
102
|
+
/** Per-launch bridge config; replaces the global `intercomBridge` config exactly as the tool and delegation overrides do. */
|
|
103
|
+
intercomBridge?: IntercomBridgeConfig;
|
|
104
|
+
/**
|
|
105
|
+
* Supervisor session target the host will hand to the child. Only a custom
|
|
106
|
+
* bridge instruction file that names the session needs it; the default
|
|
107
|
+
* template is session-independent.
|
|
108
|
+
*/
|
|
109
|
+
orchestratorTarget?: string;
|
|
89
110
|
}
|
|
90
111
|
|
|
112
|
+
/** Bridge activation before tool capability ceilings are applied. */
|
|
113
|
+
export type SubagentLaunchContractIntercomBridge =
|
|
114
|
+
| { active: true; mode: Exclude<IntercomBridgeMode, "off"> }
|
|
115
|
+
| { active: false; mode: IntercomBridgeMode };
|
|
116
|
+
|
|
91
117
|
export interface SubagentLaunchContractAgentCandidate {
|
|
92
118
|
name: string;
|
|
93
119
|
localName?: string;
|
|
@@ -128,6 +154,7 @@ export interface SubagentLaunchContractTools {
|
|
|
128
154
|
toolExtensionPaths: string[];
|
|
129
155
|
runtimeExtensions: string[];
|
|
130
156
|
configuredExtensions: string[];
|
|
157
|
+
requiredExtensionIds: string[];
|
|
131
158
|
extensionArgs: string[];
|
|
132
159
|
disableAmbientExtensions: boolean;
|
|
133
160
|
fanoutAuthorized: boolean;
|
|
@@ -159,7 +186,6 @@ export interface SubagentLaunchContract {
|
|
|
159
186
|
agent: SubagentLaunchContractAgent;
|
|
160
187
|
context: "fresh" | "fork";
|
|
161
188
|
model?: string;
|
|
162
|
-
modelCandidates: string[];
|
|
163
189
|
thinking?: string;
|
|
164
190
|
thinkingCeiling?: ThinkingLevel;
|
|
165
191
|
sandbox?: string;
|
|
@@ -169,6 +195,7 @@ export interface SubagentLaunchContract {
|
|
|
169
195
|
inheritSkills: boolean;
|
|
170
196
|
skills: SubagentLaunchContractSkills;
|
|
171
197
|
tools: SubagentLaunchContractTools;
|
|
198
|
+
intercomBridge: SubagentLaunchContractIntercomBridge;
|
|
172
199
|
roots: SubagentLaunchContractRoots;
|
|
173
200
|
protocol: {
|
|
174
201
|
lifecycleArtifactVersion: number;
|
|
@@ -268,6 +295,15 @@ export async function resolveSubagentLaunchContract(input: SubagentLaunchContrac
|
|
|
268
295
|
if (input.artifactDir !== undefined && input.artifactDir !== "project" && input.artifactDir !== "session" && input.artifactDir !== "temp") {
|
|
269
296
|
return { ok: false, code: "invalid_artifact_dir", message: `Unsupported artifactDir '${String(input.artifactDir)}'; expected 'project', 'session', or 'temp'.`, diagnostics };
|
|
270
297
|
}
|
|
298
|
+
const bridgeOverride = input.intercomBridge === undefined ? undefined : validateIntercomBridgeConfig({ value: input.intercomBridge, label: "intercomBridge" });
|
|
299
|
+
if (bridgeOverride && !bridgeOverride.ok) {
|
|
300
|
+
return { ok: false, code: "invalid_intercom_bridge", message: bridgeOverride.error, diagnostics };
|
|
301
|
+
}
|
|
302
|
+
// Execution always derives a non-empty target, so an empty one here would
|
|
303
|
+
// silently deactivate the bridge and break parity instead of proving it.
|
|
304
|
+
if (input.orchestratorTarget !== undefined && (typeof input.orchestratorTarget !== "string" || !input.orchestratorTarget.trim())) {
|
|
305
|
+
return { ok: false, code: "invalid_intercom_bridge", message: "orchestratorTarget must be a non-empty string when provided.", diagnostics };
|
|
306
|
+
}
|
|
271
307
|
const scope = resolveExecutionAgentScope(input.agentScope);
|
|
272
308
|
const parentProvider = input.preferredProvider ?? input.parentModel?.provider;
|
|
273
309
|
const discovery = discoverAgentSnapshot(effectiveCwd, scope, parentProvider, { includeChains: false });
|
|
@@ -287,7 +323,32 @@ export async function resolveSubagentLaunchContract(input: SubagentLaunchContrac
|
|
|
287
323
|
if (!resolvedAgent.agent) {
|
|
288
324
|
return { ok: false, code: "missing_agent", message: formatUnknownAgentError(input.agent, unknownAgentDiagnosticContext(discovered)), diagnostics };
|
|
289
325
|
}
|
|
290
|
-
const
|
|
326
|
+
const definitionAgent = resolvedAgent.agent;
|
|
327
|
+
let extensionBindings: ExtensionBindings | undefined;
|
|
328
|
+
try {
|
|
329
|
+
extensionBindings = normalizeExtensionBindings(input.extensionBindings)?.value;
|
|
330
|
+
} catch (error) {
|
|
331
|
+
return { ok: false, code: "invalid_extension_bindings", message: error instanceof Error ? error.message : String(error), diagnostics };
|
|
332
|
+
}
|
|
333
|
+
if (extensionBindings !== undefined && (definitionAgent.runner?.type === "external-cli" || definitionAgent.runner?.type === "external-job")) {
|
|
334
|
+
return { ok: false, code: "unsupported_mode", message: `extensionBindings is not supported for runner.type='${definitionAgent.runner.type}'.`, diagnostics };
|
|
335
|
+
}
|
|
336
|
+
const context = resolveLaunchContractContext(input, definitionAgent);
|
|
337
|
+
if (context === "fork") {
|
|
338
|
+
diagnostics.push({ code: "host_required", severity: "host-required", message: "Exact fork session branching requires Pi host session snapshots." });
|
|
339
|
+
}
|
|
340
|
+
// Execution rewrites the discovered agent through the bridge before any
|
|
341
|
+
// other launch resolution, so preflight must hash the same rewritten agent.
|
|
342
|
+
const bridge = resolveIntercomBridge({
|
|
343
|
+
config: loadConfig().intercomBridge,
|
|
344
|
+
...(bridgeOverride ? { override: bridgeOverride.value } : {}),
|
|
345
|
+
context,
|
|
346
|
+
orchestratorTarget: input.orchestratorTarget ?? PREFLIGHT_ORCHESTRATOR_TARGET,
|
|
347
|
+
});
|
|
348
|
+
if (bridge.active && bridge.interpolatesOrchestratorTarget && input.orchestratorTarget === undefined) {
|
|
349
|
+
diagnostics.push({ code: "host_required", severity: "host-required", message: "The intercomBridge instruction file names the supervisor session; supply orchestratorTarget to bind the exact child prompt." });
|
|
350
|
+
}
|
|
351
|
+
const agent = applyIntercomBridgeToAgent(definitionAgent, bridge);
|
|
291
352
|
const trustedProjectCwd = input.projectTrusted === true
|
|
292
353
|
? path.resolve(input.trustedProjectCwd ?? effectiveCwd)
|
|
293
354
|
: undefined;
|
|
@@ -315,19 +376,6 @@ export async function resolveSubagentLaunchContract(input: SubagentLaunchContrac
|
|
|
315
376
|
const message = `Agent '${agent.name}' requests permission profile '${agent.permissionProfile}', but runner.type='${agent.runner.type}' cannot load the native pi-permission-system extension.`;
|
|
316
377
|
return { ok: false, code: "unsupported_mode", message, diagnostics: [{ code: "unsupported_mode", severity: "error", message }] };
|
|
317
378
|
}
|
|
318
|
-
let extensionBindings: ExtensionBindings | undefined;
|
|
319
|
-
try {
|
|
320
|
-
extensionBindings = normalizeExtensionBindings(input.extensionBindings)?.value;
|
|
321
|
-
} catch (error) {
|
|
322
|
-
return { ok: false, code: "invalid_extension_bindings", message: error instanceof Error ? error.message : String(error), diagnostics };
|
|
323
|
-
}
|
|
324
|
-
if (extensionBindings !== undefined && (agent.runner?.type === "external-cli" || agent.runner?.type === "external-job")) {
|
|
325
|
-
return { ok: false, code: "unsupported_mode", message: `extensionBindings is not supported for runner.type='${agent.runner.type}'.`, diagnostics };
|
|
326
|
-
}
|
|
327
|
-
const context = resolveLaunchContractContext(input, agent);
|
|
328
|
-
if (context === "fork") {
|
|
329
|
-
diagnostics.push({ code: "host_required", severity: "host-required", message: "Exact fork session branching and fork-thinking downgrade checks require Pi host session and model-registry snapshots." });
|
|
330
|
-
}
|
|
331
379
|
const effectiveCapabilityCeiling = intersectSubagentCapabilityCeilings(input.capabilityCeiling, input.inheritedCapabilityCeiling);
|
|
332
380
|
const restrictionMessage = capabilityCeilingAgentRestrictionMessage(agent.name, effectiveCapabilityCeiling);
|
|
333
381
|
if (restrictionMessage) return { ok: false, code: "restricted_agent", message: restrictionMessage, diagnostics };
|
|
@@ -339,6 +387,7 @@ export async function resolveSubagentLaunchContract(input: SubagentLaunchContrac
|
|
|
339
387
|
...(input.outputMode !== undefined ? { outputMode: input.outputMode } : {}),
|
|
340
388
|
...(skillInput !== undefined ? { skills: skillInput } : {}),
|
|
341
389
|
...(input.model !== undefined ? { model: input.model } : {}),
|
|
390
|
+
...(input.outputSchema !== undefined ? { outputSchema: input.outputSchema } : {}),
|
|
342
391
|
});
|
|
343
392
|
const requestedSkills = behavior.skills === false ? [] : behavior.skills;
|
|
344
393
|
const resolvedSkills = resolveSkillsWithFallback(
|
|
@@ -354,6 +403,9 @@ export async function resolveSubagentLaunchContract(input: SubagentLaunchContrac
|
|
|
354
403
|
if (resolvedSkills.missing.length > 0) diagnostics.push({ code: "missing_skill", severity: "error", message: `Missing skills: ${resolvedSkills.missing.join(", ")}` });
|
|
355
404
|
|
|
356
405
|
const externalRunner = agent.runner?.type === "external-cli" || agent.runner?.type === "external-job";
|
|
406
|
+
if (externalRunner && behavior.outputSchema) {
|
|
407
|
+
return { ok: false, code: "unsupported_mode", message: `Agent '${agent.name}' uses runner.type='${agent.runner?.type}' and does not support: structured output.`, diagnostics };
|
|
408
|
+
}
|
|
357
409
|
const availableModels = normalizeAvailableModels(input.availableModels);
|
|
358
410
|
const preferredProvider = agent.modelProvider ?? input.preferredProvider ?? input.parentModel?.provider;
|
|
359
411
|
const modelScopes = resolveModelScopesForAgent(discovered.modelScope, agent.name, input.parentModel);
|
|
@@ -370,19 +422,14 @@ export async function resolveSubagentLaunchContract(input: SubagentLaunchContrac
|
|
|
370
422
|
input.thinkingCeiling,
|
|
371
423
|
input.inheritedThinkingCeiling,
|
|
372
424
|
);
|
|
373
|
-
const model = externalRunner ? undefined : applyThinkingSuffix(primaryModel,
|
|
374
|
-
const modelCandidates = externalRunner
|
|
375
|
-
? []
|
|
376
|
-
: buildModelCandidates(primaryModel, agent.fallbackModels, availableModels, preferredProvider, {
|
|
425
|
+
const model = externalRunner ? undefined : applyThinkingSuffix(resolveModelSelection(primaryModel, availableModels, preferredProvider, {
|
|
377
426
|
scope: modelScopes,
|
|
378
427
|
primaryModelFromParent: modelOrigin === "inherited" || inheritsParentModel(input.model, agent.model, input.parentModel),
|
|
379
428
|
origin: modelOrigin,
|
|
380
|
-
})
|
|
381
|
-
.map((candidate) => applyThinkingSuffix(candidate, effectiveThinkingConfig, input.thinking !== undefined) ?? candidate);
|
|
429
|
+
}).model, effectiveThinkingConfig, input.thinking !== undefined);
|
|
382
430
|
if (!externalRunner) {
|
|
383
431
|
try {
|
|
384
432
|
assertThinkingWithinCeiling({ model, configThinking: effectiveThinkingConfig, ceiling: thinkingCeiling, agent: agent.name, runId });
|
|
385
|
-
for (const candidate of modelCandidates) assertThinkingWithinCeiling({ model: candidate, configThinking: effectiveThinkingConfig, ceiling: thinkingCeiling, agent: agent.name, runId });
|
|
386
433
|
} catch (error) {
|
|
387
434
|
const message = error instanceof Error ? error.message : String(error);
|
|
388
435
|
diagnostics.push({ code: "thinking_ceiling", severity: "error", message });
|
|
@@ -392,6 +439,7 @@ export async function resolveSubagentLaunchContract(input: SubagentLaunchContrac
|
|
|
392
439
|
let toolPlan: PiLaunchToolPlan;
|
|
393
440
|
const permissionRules = resolvePermissionRules(loadConfig().permissions, agent.permissions);
|
|
394
441
|
const fast = input.fast ?? agent.fast;
|
|
442
|
+
const requiredExtensions = externalRunner ? [] : resolveRequiredChildExtensions(input.parentSessionId);
|
|
395
443
|
try {
|
|
396
444
|
toolPlan = resolvePiLaunchToolPlan({
|
|
397
445
|
tools: agent.tools,
|
|
@@ -399,18 +447,19 @@ export async function resolveSubagentLaunchContract(input: SubagentLaunchContrac
|
|
|
399
447
|
allowNestedSubagents: agent.allowNestedSubagents,
|
|
400
448
|
extensions: agent.extensions,
|
|
401
449
|
subagentOnlyExtensions: agent.subagentOnlyExtensions,
|
|
450
|
+
requiredExtensions,
|
|
402
451
|
mcpDirectTools: agent.mcpDirectTools,
|
|
403
452
|
cwd: effectiveCwd,
|
|
404
453
|
requireReadTool: resolvedSkills.resolved.length > 0,
|
|
405
|
-
structuredOutput: Boolean(
|
|
454
|
+
structuredOutput: Boolean(behavior.outputSchema),
|
|
406
455
|
fast,
|
|
407
456
|
model,
|
|
408
|
-
modelCandidates,
|
|
409
457
|
capabilityCeiling: effectiveCapabilityCeiling,
|
|
410
458
|
agentName: agent.name,
|
|
411
459
|
permissionRules,
|
|
412
460
|
sandbox: agent.sandbox,
|
|
413
461
|
permissionProfile: agent.permissionProfile,
|
|
462
|
+
hostAvailableBuiltins: input.hostAvailableBuiltins,
|
|
414
463
|
});
|
|
415
464
|
} catch (error) {
|
|
416
465
|
const message = error instanceof Error ? error.message : String(error);
|
|
@@ -422,7 +471,10 @@ export async function resolveSubagentLaunchContract(input: SubagentLaunchContrac
|
|
|
422
471
|
const artifactsDir = artifactsEnabled ? getArtifactsDir(input.parentSessionFile ?? null, effectiveCwd, input.artifactDir) : undefined;
|
|
423
472
|
const artifactPaths = artifactsDir ? getArtifactPaths(artifactsDir, runId, agent.name, 0) : undefined;
|
|
424
473
|
const outputPath = resolveSingleOutputPath(behavior.output, effectiveCwd, effectiveCwd, artifactsDir ? path.join(artifactsDir, "outputs", runId) : undefined);
|
|
425
|
-
|
|
474
|
+
// An explicit sessionDir is a root keyed by the child run id, matching the
|
|
475
|
+
// sibling sessionRoot derivation; hosts omitting runId get the documented
|
|
476
|
+
// deterministic "preflight" placeholder.
|
|
477
|
+
const sessionRoot = input.sessionDir ? path.join(path.resolve(input.sessionDir), runId) : input.sessionRoot ? path.join(path.resolve(input.sessionRoot), runId) : undefined;
|
|
426
478
|
const sessionDir = sessionRoot ? path.join(sessionRoot, "run-0") : undefined;
|
|
427
479
|
const lifecycleAsyncDir = input.nestedRootRunId
|
|
428
480
|
? path.join(TEMP_ROOT_DIR, "nested-subagent-runs", input.nestedRootRunId, runId)
|
|
@@ -437,17 +489,25 @@ export async function resolveSubagentLaunchContract(input: SubagentLaunchContrac
|
|
|
437
489
|
if (resolvedSkills.missing.length > 0) {
|
|
438
490
|
return { ok: false, code: "missing_skill", message: `Missing skills: ${resolvedSkills.missing.join(", ")}`, diagnostics };
|
|
439
491
|
}
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
492
|
+
const effectiveThinking = resolveEffectiveThinking(model, effectiveThinkingConfig);
|
|
493
|
+
const binding = resolveLaunchBinding({
|
|
494
|
+
agent,
|
|
495
|
+
task: input.task ?? "",
|
|
496
|
+
model,
|
|
497
|
+
...(fast !== undefined ? { fast } : {}),
|
|
498
|
+
...(effectiveThinking ? { thinking: effectiveThinking } : {}),
|
|
499
|
+
...(agent.sandbox ? { sandbox: agent.sandbox } : {}),
|
|
500
|
+
...(agent.permissionProfile ? { permissionProfile: agent.permissionProfile } : {}),
|
|
501
|
+
systemPrompt: buildEffectiveSystemPrompt({ agent, resolvedSkills: resolvedSkills.resolved, cwd: effectiveCwd, ...(outputPath ? { outputPath } : {}) }),
|
|
502
|
+
skills: requestedSkills,
|
|
503
|
+
toolPlan,
|
|
504
|
+
...(outputPath ? { outputPath } : {}),
|
|
505
|
+
outputMode: behavior.outputMode,
|
|
506
|
+
...(behavior.outputSchema ? { structuredOutputSchema: behavior.outputSchema } : {}),
|
|
507
|
+
...(extensionBindings ? { extensionBindings } : {}),
|
|
508
|
+
});
|
|
448
509
|
const candidates = candidateList(input.agent, agent, discovery.all);
|
|
449
510
|
const shadowedCandidates = candidates.filter((candidate) => !candidate.selected);
|
|
450
|
-
const definitionDigest = agentDefinitionDigest(agent);
|
|
451
511
|
const contractBase: Omit<SubagentLaunchContract, "digest"> = {
|
|
452
512
|
version: SUBAGENT_LAUNCH_CONTRACT_VERSION,
|
|
453
513
|
runId,
|
|
@@ -458,13 +518,12 @@ export async function resolveSubagentLaunchContract(input: SubagentLaunchContrac
|
|
|
458
518
|
source: agent.source,
|
|
459
519
|
filePath: agent.filePath,
|
|
460
520
|
definitionProjectionVersion: AGENT_DEFINITION_PROJECTION_VERSION,
|
|
461
|
-
definitionDigest,
|
|
521
|
+
definitionDigest: binding.definitionDigest,
|
|
462
522
|
shadowedCandidates,
|
|
463
523
|
},
|
|
464
524
|
context,
|
|
465
525
|
...(model ? { model } : {}),
|
|
466
|
-
|
|
467
|
-
...(resolveEffectiveThinking(model, effectiveThinkingConfig) ? { thinking: resolveEffectiveThinking(model, effectiveThinkingConfig) } : {}),
|
|
526
|
+
...(effectiveThinking ? { thinking: effectiveThinking } : {}),
|
|
468
527
|
...(thinkingCeiling ? { thinkingCeiling } : {}),
|
|
469
528
|
...(agent.sandbox ? { sandbox: agent.sandbox } : {}),
|
|
470
529
|
...(agent.permissionProfile ? { permissionProfile: agent.permissionProfile } : {}),
|
|
@@ -490,12 +549,15 @@ export async function resolveSubagentLaunchContract(input: SubagentLaunchContrac
|
|
|
490
549
|
toolExtensionPaths: toolPlan.toolExtensionPaths,
|
|
491
550
|
runtimeExtensions: toolPlan.runtimeExtensions,
|
|
492
551
|
configuredExtensions: toolPlan.configuredExtensions,
|
|
493
|
-
|
|
552
|
+
requiredExtensionIds: toolPlan.requiredExtensions.map(({ id }) => id),
|
|
553
|
+
// Required paths are private launch authority; preflight exposes their safe IDs above.
|
|
554
|
+
extensionArgs: toolPlan.extensionArgs.filter((extensionPath) => !requiredExtensions.some(({ path }) => path === extensionPath)),
|
|
494
555
|
disableAmbientExtensions: toolPlan.disableAmbientExtensions,
|
|
495
556
|
fanoutAuthorized: toolPlan.fanoutAuthorized,
|
|
496
557
|
...(toolPlan.capabilityCeiling ? { capabilityCeiling: toolPlan.capabilityCeiling } : {}),
|
|
497
558
|
...(toolPlan.capabilityAudit ? { capabilityAudit: toolPlan.capabilityAudit } : {}),
|
|
498
559
|
},
|
|
560
|
+
intercomBridge: bridge.active && bridge.mode !== "off" ? { active: true, mode: bridge.mode } : { active: false, mode: bridge.mode },
|
|
499
561
|
roots: {
|
|
500
562
|
cwd: effectiveCwd,
|
|
501
563
|
...(sessionRoot ? { sessionRoot } : {}),
|
|
@@ -517,30 +579,7 @@ export async function resolveSubagentLaunchContract(input: SubagentLaunchContrac
|
|
|
517
579
|
packageVersion: packageVersion(),
|
|
518
580
|
},
|
|
519
581
|
diagnostics,
|
|
520
|
-
launchContractDigest:
|
|
521
|
-
task: input.task ?? "",
|
|
522
|
-
definitionDigest,
|
|
523
|
-
...(model ? { model } : {}),
|
|
524
|
-
modelCandidates,
|
|
525
|
-
...(fast !== undefined ? { fast } : {}),
|
|
526
|
-
...(resolveEffectiveThinking(model, effectiveThinkingConfig) ? { thinking: resolveEffectiveThinking(model, effectiveThinkingConfig) } : {}),
|
|
527
|
-
systemPrompt: effectiveSystemPrompt,
|
|
528
|
-
systemPromptMode: agent.systemPromptMode,
|
|
529
|
-
inheritProjectContext: agent.inheritProjectContext,
|
|
530
|
-
inheritGlobalContext: agent.inheritGlobalContext,
|
|
531
|
-
inheritSkills: agent.inheritSkills,
|
|
532
|
-
sandbox: agent.sandbox,
|
|
533
|
-
permissionProfile: agent.permissionProfile,
|
|
534
|
-
skills: requestedSkills,
|
|
535
|
-
tools: toolPlan.effectiveToolAllowlist,
|
|
536
|
-
...(toolPlan.excludeTools.length > 0 ? { excludeTools: toolPlan.excludeTools } : {}),
|
|
537
|
-
extensions: toolPlan.extensionArgs,
|
|
538
|
-
mcpDirectTools: toolPlan.effectiveMcpTools,
|
|
539
|
-
...(outputPath ? { outputPath } : {}),
|
|
540
|
-
outputMode: behavior.outputMode,
|
|
541
|
-
...(input.outputSchema ? { structuredOutputSchema: input.outputSchema } : {}),
|
|
542
|
-
...(extensionBindings ? { extensionBindings } : {}),
|
|
543
|
-
}),
|
|
582
|
+
launchContractDigest: binding.launchContractDigest,
|
|
544
583
|
};
|
|
545
584
|
return { ok: true, contract: { ...contractBase, digest: digestContract(contractBase) } };
|
|
546
585
|
}
|
package/src/api/shared-types.ts
CHANGED
|
@@ -13,6 +13,8 @@ export {
|
|
|
13
13
|
type ExecutionProjection,
|
|
14
14
|
type ExternalJobRunnerStatus,
|
|
15
15
|
type ExternalJobStatus,
|
|
16
|
+
type IntercomBridgeConfig,
|
|
17
|
+
type IntercomBridgeMode,
|
|
16
18
|
type JsonSchemaObject,
|
|
17
19
|
type OutputMode,
|
|
18
20
|
type ReviewProjection,
|
|
@@ -23,5 +25,5 @@ export {
|
|
|
23
25
|
type ManagedWorktreeProvider,
|
|
24
26
|
type WorktreeNaming,
|
|
25
27
|
type WorktreeProvider,
|
|
26
|
-
type
|
|
28
|
+
type WorkflowResourceProvenance,
|
|
27
29
|
} from "../shared/types.ts";
|
package/src/extension/config.ts
CHANGED
|
@@ -6,10 +6,10 @@ import { FLEET_KEYBINDING_ACTIONS, type ArtifactDirPreference, type ExtensionCon
|
|
|
6
6
|
import { validateMissionStoreConfig } from "../missions/store.ts";
|
|
7
7
|
import { validateAuthorityPolicy } from "../policy/authority.ts";
|
|
8
8
|
import { getAgentDir } from "../shared/utils.ts";
|
|
9
|
-
import { DEFAULT_MODEL_EXCLUSION_TTL_MS, MAX_MODEL_EXCLUSION_TTL_MS, setDefaultTTL } from "../runs/shared/model-exclusions.ts";
|
|
10
9
|
import { validatePermissionConfig } from "../runs/shared/permissions.ts";
|
|
11
10
|
import { MAX_ABANDONED_SLOT_RELEASE_AFTER_MS, MIN_ABANDONED_SLOT_RELEASE_AFTER_MS } from "../runs/background/active-async-capacity.ts";
|
|
12
11
|
import { normalizeWorktreeBranchPrefix } from "../runs/shared/worktree.ts";
|
|
12
|
+
import { validateModelResponseAliases } from "../shared/model-response-aliases.ts";
|
|
13
13
|
|
|
14
14
|
const ARTIFACT_DIR_PREFERENCES = new Set<ArtifactDirPreference>(["project", "session", "temp"]);
|
|
15
15
|
const FLEET_KEYBINDING_ACTION_SET = new Set<string>(FLEET_KEYBINDING_ACTIONS);
|
|
@@ -96,17 +96,6 @@ function validateCapacityConfig(value: unknown): void {
|
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
-
/** Validate the user-controlled TTL policy before it reaches the exclusion store. */
|
|
100
|
-
// TEST:test/unit/pi-coding-agent-dir.test.ts[loads and applies model exclusion TTL config]
|
|
101
|
-
function validateModelExclusionsConfig(value: unknown): void {
|
|
102
|
-
if (value === undefined) return;
|
|
103
|
-
if (!value || typeof value !== "object" || Array.isArray(value)) throw new Error("config.modelExclusions must be a JSON object");
|
|
104
|
-
const defaultTtlMs = (value as Record<string, unknown>).defaultTtlMs;
|
|
105
|
-
if (defaultTtlMs !== undefined && (typeof defaultTtlMs !== "number" || !Number.isFinite(defaultTtlMs) || defaultTtlMs <= 0 || defaultTtlMs > MAX_MODEL_EXCLUSION_TTL_MS)) {
|
|
106
|
-
throw new Error(`config.modelExclusions.defaultTtlMs must be a finite positive number no greater than ${MAX_MODEL_EXCLUSION_TTL_MS}`);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
99
|
function validateOrcaProgressTabsConfig(value: unknown): void {
|
|
111
100
|
if (value === undefined) return;
|
|
112
101
|
if (!value || typeof value !== "object" || Array.isArray(value)) throw new Error("config.orcaProgressTabs must be a JSON object");
|
|
@@ -153,6 +142,13 @@ function validateConfig(config: Record<string, unknown>): void {
|
|
|
153
142
|
throw new Error('config.defaultSubagentContext must be "fresh" or "fork"');
|
|
154
143
|
}
|
|
155
144
|
validateForkContextConfig(config.forkContext);
|
|
145
|
+
if (config.checkpointBeforeDeadlineMs !== undefined
|
|
146
|
+
&& (typeof config.checkpointBeforeDeadlineMs !== "number"
|
|
147
|
+
|| !Number.isInteger(config.checkpointBeforeDeadlineMs)
|
|
148
|
+
|| config.checkpointBeforeDeadlineMs <= 0
|
|
149
|
+
|| config.checkpointBeforeDeadlineMs > 2_147_483_647)) {
|
|
150
|
+
throw new Error("config.checkpointBeforeDeadlineMs must be a positive integer no larger than 2147483647");
|
|
151
|
+
}
|
|
156
152
|
if (config.foregroundDetachShortcut !== undefined
|
|
157
153
|
&& (typeof config.foregroundDetachShortcut !== "string" || !isValidKeyId(config.foregroundDetachShortcut))) {
|
|
158
154
|
throw new Error("config.foregroundDetachShortcut must be a valid keybinding string such as \"ctrl+b\"");
|
|
@@ -176,7 +172,8 @@ function validateConfig(config: Record<string, unknown>): void {
|
|
|
176
172
|
validateFleetKeybindingsConfig(config.fleetKeybindings);
|
|
177
173
|
validateArtifactConfig(config.artifactConfig);
|
|
178
174
|
validateCapacityConfig(config.capacity);
|
|
179
|
-
|
|
175
|
+
if (config.modelExclusions !== undefined) throw new Error("config.modelExclusions was removed; model failures are no longer persisted or used for automatic switching");
|
|
176
|
+
validateModelResponseAliases(config.modelResponseAliases);
|
|
180
177
|
validateMainWindowRendererConfig(config.mainWindowRenderer);
|
|
181
178
|
validateOrcaProgressTabsConfig(config.orcaProgressTabs);
|
|
182
179
|
}
|
|
@@ -187,6 +184,8 @@ export function getConfigPath(): string {
|
|
|
187
184
|
|
|
188
185
|
function readConfigForUpdate(configPath = getConfigPath()): ExtensionConfig {
|
|
189
186
|
if (!fs.existsSync(configPath)) return {};
|
|
187
|
+
// Upstream-original: config parse is guarded by the object check below, which throws a domain error.
|
|
188
|
+
// pi-lens-ignore: unchecked-throwing-call-js
|
|
190
189
|
const parsed = JSON.parse(fs.readFileSync(configPath, "utf-8")) as unknown;
|
|
191
190
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
192
191
|
throw new Error(`Subagent config at '${configPath}' must be a JSON object`);
|
|
@@ -208,28 +207,6 @@ export function updateConfig(updater: (config: ExtensionConfig) => ExtensionConf
|
|
|
208
207
|
return next;
|
|
209
208
|
}
|
|
210
209
|
|
|
211
|
-
/**
|
|
212
|
-
* Resolve the default TTL that the process-wide exclusion store should use.
|
|
213
|
-
*
|
|
214
|
-
* @param config Extension configuration after validation.
|
|
215
|
-
* @returns The configured TTL in milliseconds, or the built-in 24-hour default.
|
|
216
|
-
*/
|
|
217
|
-
// TEST:test/unit/pi-coding-agent-dir.test.ts[loads and applies model exclusion TTL config]
|
|
218
|
-
export function resolveModelExclusionTTL(config: Pick<ExtensionConfig, "modelExclusions">): number {
|
|
219
|
-
return config.modelExclusions?.defaultTtlMs ?? DEFAULT_MODEL_EXCLUSION_TTL_MS;
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
/**
|
|
223
|
-
* Apply the configured exclusion policy to the process-wide model store.
|
|
224
|
-
*
|
|
225
|
-
* @param config Extension configuration after validation.
|
|
226
|
-
* @returns Nothing.
|
|
227
|
-
*/
|
|
228
|
-
// TEST:test/unit/pi-coding-agent-dir.test.ts[loads and applies model exclusion TTL config]
|
|
229
|
-
export function applyModelExclusionsConfig(config: Pick<ExtensionConfig, "modelExclusions">): void {
|
|
230
|
-
setDefaultTTL(resolveModelExclusionTTL(config), { shortenExisting: config.modelExclusions?.defaultTtlMs !== undefined });
|
|
231
|
-
}
|
|
232
|
-
|
|
233
210
|
export function resolveAsyncByDefault(config: Pick<ExtensionConfig, "asyncByDefault">): boolean {
|
|
234
211
|
return config.asyncByDefault !== false;
|
|
235
212
|
}
|
|
@@ -240,12 +217,12 @@ export function loadConfig(): ExtensionConfig {
|
|
|
240
217
|
return readConfigForUpdate(configPath);
|
|
241
218
|
} catch (error) {
|
|
242
219
|
if (error instanceof PrunedForkConfigError) throw error;
|
|
243
|
-
//
|
|
220
|
+
// Explicit route identity, worktree, and checkpoint policies must not be silently
|
|
244
221
|
// discarded and replaced by the built-in defaults after validation fails.
|
|
245
222
|
try {
|
|
246
223
|
const raw = JSON.parse(fs.readFileSync(configPath, "utf-8")) as unknown;
|
|
247
224
|
if (raw && typeof raw === "object" && !Array.isArray(raw)
|
|
248
|
-
&& (Object.hasOwn(raw, "worktreeProvider") || Object.hasOwn(raw, "worktreeBranchPrefix"))) throw error;
|
|
225
|
+
&& (Object.hasOwn(raw, "worktreeProvider") || Object.hasOwn(raw, "worktreeBranchPrefix") || Object.hasOwn(raw, "modelResponseAliases") || Object.hasOwn(raw, "modelExclusions") || Object.hasOwn(raw, "checkpointBeforeDeadlineMs"))) throw error;
|
|
249
226
|
} catch (readError) {
|
|
250
227
|
if (readError === error) throw error;
|
|
251
228
|
}
|