@xzzpig/pi-subagents 0.14.0 → 0.15.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +239 -0
- package/README.md +7 -6
- package/agents/evidence-auditor.md +34 -0
- package/agents/researcher.md +23 -13
- package/agents/reviewer.md +3 -2
- package/docs/agents.md +55 -136
- package/docs/configuration.md +92 -14
- package/docs/extension-api.md +132 -74
- package/docs/fork-extensions.md +184 -0
- 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-eject.ts +339 -0
- package/src/agents/agent-management.ts +79 -387
- 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/agent-management.ts +2 -2
- package/src/api/delegation.ts +4 -0
- package/src/api/preflight.ts +131 -86
- 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 +38 -35
- 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 +770 -444
- 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 +915 -411
- 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 +49 -85
- 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 +149 -112
- 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 +27 -34
- 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/profile-extensions.ts +134 -0
- package/src/runs/shared/profile-launch-env.ts +113 -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/sandbox-profile-guard.ts +34 -0
- 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/permission-profile.ts +14 -0
- package/src/shared/pruned-fork.ts +1 -1
- package/src/shared/required-child-extensions.ts +81 -0
- package/src/shared/sandbox-profile.ts +14 -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] } : {}),
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
export { AGENT_MANAGEMENT_API_VERSION } from "../agents/agent-management.ts";
|
|
1
2
|
export {
|
|
2
|
-
AGENT_MANAGEMENT_API_VERSION,
|
|
3
3
|
ejectAgentDefinition,
|
|
4
4
|
type AgentEjectionErrorCode,
|
|
5
5
|
type AgentEjectionScope,
|
|
6
6
|
type EjectAgentDefinitionInput,
|
|
7
7
|
type EjectAgentDefinitionResult,
|
|
8
8
|
type EjectAgentDefinitionVerification,
|
|
9
|
-
} from "../agents/agent-
|
|
9
|
+
} from "../agents/agent-eject.ts";
|
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,38 @@ 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 { projectScopedProfileTrustError } from "../runs/shared/sandbox-profile-guard.ts";
|
|
30
|
+
import { resolveRequiredChildExtensions } from "../shared/required-child-extensions.ts";
|
|
28
31
|
|
|
29
|
-
|
|
32
|
+
// v3: the contract reports the resolved Intercom bridge state and binds its
|
|
33
|
+
// prompt and tools into launchContractDigest, matching execution (#2127).
|
|
34
|
+
export const SUBAGENT_LAUNCH_CONTRACT_VERSION = 3 as const;
|
|
35
|
+
|
|
36
|
+
/** Stands in for the parent session target when the host does not supply one; only custom templates that name the session read it. */
|
|
37
|
+
const PREFLIGHT_ORCHESTRATOR_TARGET = "preflight";
|
|
30
38
|
|
|
31
39
|
export type SubagentLaunchContractReasonCode =
|
|
32
40
|
| "missing_agent"
|
|
@@ -41,7 +49,8 @@ export type SubagentLaunchContractReasonCode =
|
|
|
41
49
|
| "invalid_extension_bindings"
|
|
42
50
|
| "untrusted_project"
|
|
43
51
|
| "sandbox_unavailable"
|
|
44
|
-
| "permission_profile_unavailable"
|
|
52
|
+
| "permission_profile_unavailable"
|
|
53
|
+
| "invalid_intercom_bridge";
|
|
45
54
|
|
|
46
55
|
export type SubagentLaunchContractDiagnosticCode = SubagentLaunchContractReasonCode | "host_required" | "snapshot_warning" | "workspace_scope_authority";
|
|
47
56
|
|
|
@@ -68,14 +77,17 @@ export interface SubagentLaunchContractInput {
|
|
|
68
77
|
skill?: string | string[] | boolean;
|
|
69
78
|
output?: string | boolean;
|
|
70
79
|
outputMode?: OutputMode;
|
|
71
|
-
outputSchema?: JsonSchemaObject;
|
|
80
|
+
outputSchema?: JsonSchemaObject | false;
|
|
72
81
|
extensionBindings?: ExtensionBindings;
|
|
73
82
|
artifacts?: boolean;
|
|
74
83
|
artifactDir?: ArtifactDirPreference;
|
|
75
84
|
parentSessionFile?: string | null;
|
|
85
|
+
/** Parent session whose host-required child extension snapshot is preflighted. */
|
|
86
|
+
parentSessionId?: string;
|
|
76
87
|
/** Current parent leaf required before an implicit `defaultContext: fork` stays `fork`. */
|
|
77
88
|
parentLeafId?: string | null;
|
|
78
89
|
sessionRoot?: string;
|
|
90
|
+
/** Caller directory used as a root keyed by the child run id ("preflight" placeholder when runId is omitted). */
|
|
79
91
|
sessionDir?: string;
|
|
80
92
|
runId?: string;
|
|
81
93
|
/** Root run id supplied by a host when projecting nested async lifecycle paths. */
|
|
@@ -86,8 +98,23 @@ export interface SubagentLaunchContractInput {
|
|
|
86
98
|
projectTrusted?: boolean;
|
|
87
99
|
/** Exact trusted project cwd. When omitted, an affirmative trust assertion applies only to `cwd`. */
|
|
88
100
|
trustedProjectCwd?: string;
|
|
101
|
+
/** Builtin tool names the host runtime provides; used to intersect agent-declared tools. */
|
|
102
|
+
hostAvailableBuiltins?: readonly string[];
|
|
103
|
+
/** Per-launch bridge config; replaces the global `intercomBridge` config exactly as the tool and delegation overrides do. */
|
|
104
|
+
intercomBridge?: IntercomBridgeConfig;
|
|
105
|
+
/**
|
|
106
|
+
* Supervisor session target the host will hand to the child. Only a custom
|
|
107
|
+
* bridge instruction file that names the session needs it; the default
|
|
108
|
+
* template is session-independent.
|
|
109
|
+
*/
|
|
110
|
+
orchestratorTarget?: string;
|
|
89
111
|
}
|
|
90
112
|
|
|
113
|
+
/** Bridge activation before tool capability ceilings are applied. */
|
|
114
|
+
export type SubagentLaunchContractIntercomBridge =
|
|
115
|
+
| { active: true; mode: Exclude<IntercomBridgeMode, "off"> }
|
|
116
|
+
| { active: false; mode: IntercomBridgeMode };
|
|
117
|
+
|
|
91
118
|
export interface SubagentLaunchContractAgentCandidate {
|
|
92
119
|
name: string;
|
|
93
120
|
localName?: string;
|
|
@@ -128,6 +155,7 @@ export interface SubagentLaunchContractTools {
|
|
|
128
155
|
toolExtensionPaths: string[];
|
|
129
156
|
runtimeExtensions: string[];
|
|
130
157
|
configuredExtensions: string[];
|
|
158
|
+
requiredExtensionIds: string[];
|
|
131
159
|
extensionArgs: string[];
|
|
132
160
|
disableAmbientExtensions: boolean;
|
|
133
161
|
fanoutAuthorized: boolean;
|
|
@@ -159,7 +187,6 @@ export interface SubagentLaunchContract {
|
|
|
159
187
|
agent: SubagentLaunchContractAgent;
|
|
160
188
|
context: "fresh" | "fork";
|
|
161
189
|
model?: string;
|
|
162
|
-
modelCandidates: string[];
|
|
163
190
|
thinking?: string;
|
|
164
191
|
thinkingCeiling?: ThinkingLevel;
|
|
165
192
|
sandbox?: string;
|
|
@@ -169,6 +196,7 @@ export interface SubagentLaunchContract {
|
|
|
169
196
|
inheritSkills: boolean;
|
|
170
197
|
skills: SubagentLaunchContractSkills;
|
|
171
198
|
tools: SubagentLaunchContractTools;
|
|
199
|
+
intercomBridge: SubagentLaunchContractIntercomBridge;
|
|
172
200
|
roots: SubagentLaunchContractRoots;
|
|
173
201
|
protocol: {
|
|
174
202
|
lifecycleArtifactVersion: number;
|
|
@@ -268,6 +296,15 @@ export async function resolveSubagentLaunchContract(input: SubagentLaunchContrac
|
|
|
268
296
|
if (input.artifactDir !== undefined && input.artifactDir !== "project" && input.artifactDir !== "session" && input.artifactDir !== "temp") {
|
|
269
297
|
return { ok: false, code: "invalid_artifact_dir", message: `Unsupported artifactDir '${String(input.artifactDir)}'; expected 'project', 'session', or 'temp'.`, diagnostics };
|
|
270
298
|
}
|
|
299
|
+
const bridgeOverride = input.intercomBridge === undefined ? undefined : validateIntercomBridgeConfig({ value: input.intercomBridge, label: "intercomBridge" });
|
|
300
|
+
if (bridgeOverride && !bridgeOverride.ok) {
|
|
301
|
+
return { ok: false, code: "invalid_intercom_bridge", message: bridgeOverride.error, diagnostics };
|
|
302
|
+
}
|
|
303
|
+
// Execution always derives a non-empty target, so an empty one here would
|
|
304
|
+
// silently deactivate the bridge and break parity instead of proving it.
|
|
305
|
+
if (input.orchestratorTarget !== undefined && (typeof input.orchestratorTarget !== "string" || !input.orchestratorTarget.trim())) {
|
|
306
|
+
return { ok: false, code: "invalid_intercom_bridge", message: "orchestratorTarget must be a non-empty string when provided.", diagnostics };
|
|
307
|
+
}
|
|
271
308
|
const scope = resolveExecutionAgentScope(input.agentScope);
|
|
272
309
|
const parentProvider = input.preferredProvider ?? input.parentModel?.provider;
|
|
273
310
|
const discovery = discoverAgentSnapshot(effectiveCwd, scope, parentProvider, { includeChains: false });
|
|
@@ -287,25 +324,55 @@ export async function resolveSubagentLaunchContract(input: SubagentLaunchContrac
|
|
|
287
324
|
if (!resolvedAgent.agent) {
|
|
288
325
|
return { ok: false, code: "missing_agent", message: formatUnknownAgentError(input.agent, unknownAgentDiagnosticContext(discovered)), diagnostics };
|
|
289
326
|
}
|
|
290
|
-
const
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
return { ok: false, code: "untrusted_project", message, diagnostics: [{ code: "untrusted_project", severity: "error", message }] };
|
|
327
|
+
const definitionAgent = resolvedAgent.agent;
|
|
328
|
+
let extensionBindings: ExtensionBindings | undefined;
|
|
329
|
+
try {
|
|
330
|
+
extensionBindings = normalizeExtensionBindings(input.extensionBindings)?.value;
|
|
331
|
+
} catch (error) {
|
|
332
|
+
return { ok: false, code: "invalid_extension_bindings", message: error instanceof Error ? error.message : String(error), diagnostics };
|
|
297
333
|
}
|
|
298
|
-
if (
|
|
299
|
-
|
|
300
|
-
return { ok: false, code: "untrusted_project", message, diagnostics: [{ code: "untrusted_project", severity: "error", message }] };
|
|
334
|
+
if (extensionBindings !== undefined && (definitionAgent.runner?.type === "external-cli" || definitionAgent.runner?.type === "external-job")) {
|
|
335
|
+
return { ok: false, code: "unsupported_mode", message: `extensionBindings is not supported for runner.type='${definitionAgent.runner.type}'.`, diagnostics };
|
|
301
336
|
}
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
337
|
+
const context = resolveLaunchContractContext(input, definitionAgent);
|
|
338
|
+
if (context === "fork") {
|
|
339
|
+
diagnostics.push({ code: "host_required", severity: "host-required", message: "Exact fork session branching requires Pi host session snapshots." });
|
|
305
340
|
}
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
341
|
+
// Execution rewrites the discovered agent through the bridge before any
|
|
342
|
+
// other launch resolution, so preflight must hash the same rewritten agent.
|
|
343
|
+
const bridge = resolveIntercomBridge({
|
|
344
|
+
config: loadConfig().intercomBridge,
|
|
345
|
+
...(bridgeOverride ? { override: bridgeOverride.value } : {}),
|
|
346
|
+
context,
|
|
347
|
+
orchestratorTarget: input.orchestratorTarget ?? PREFLIGHT_ORCHESTRATOR_TARGET,
|
|
348
|
+
});
|
|
349
|
+
if (bridge.active && bridge.interpolatesOrchestratorTarget && input.orchestratorTarget === undefined) {
|
|
350
|
+
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." });
|
|
351
|
+
}
|
|
352
|
+
const agent = applyIntercomBridgeToAgent(definitionAgent, bridge);
|
|
353
|
+
const trustedProjectCwd = input.projectTrusted === true
|
|
354
|
+
? path.resolve(input.trustedProjectCwd ?? effectiveCwd)
|
|
355
|
+
: undefined;
|
|
356
|
+
const projectScoped = agent.source === "project" || agent.override?.scope === "project";
|
|
357
|
+
const profileTrustError = projectScopedProfileTrustError({
|
|
358
|
+
kind: "sandbox",
|
|
359
|
+
agentName: agent.name,
|
|
360
|
+
profileName: agent.sandbox ?? "",
|
|
361
|
+
projectScoped: Boolean(agent.sandbox) && projectScoped,
|
|
362
|
+
trustedCwd: trustedProjectCwd,
|
|
363
|
+
effectiveCwd,
|
|
364
|
+
messageStyle: "preflight",
|
|
365
|
+
}) ?? projectScopedProfileTrustError({
|
|
366
|
+
kind: "permission",
|
|
367
|
+
agentName: agent.name,
|
|
368
|
+
profileName: agent.permissionProfile ?? "",
|
|
369
|
+
projectScoped: Boolean(agent.permissionProfile) && projectScoped,
|
|
370
|
+
trustedCwd: trustedProjectCwd,
|
|
371
|
+
effectiveCwd,
|
|
372
|
+
messageStyle: "preflight",
|
|
373
|
+
});
|
|
374
|
+
if (profileTrustError) {
|
|
375
|
+
return { ok: false, code: "untrusted_project", message: profileTrustError, diagnostics: [{ code: "untrusted_project", severity: "error", message: profileTrustError }] };
|
|
309
376
|
}
|
|
310
377
|
if (agent.sandbox && (agent.runner?.type === "external-cli" || agent.runner?.type === "external-job")) {
|
|
311
378
|
const message = `Agent '${agent.name}' requests sandbox profile '${agent.sandbox}', but runner.type='${agent.runner.type}' cannot load the native pi-sandbox extension.`;
|
|
@@ -315,19 +382,6 @@ export async function resolveSubagentLaunchContract(input: SubagentLaunchContrac
|
|
|
315
382
|
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
383
|
return { ok: false, code: "unsupported_mode", message, diagnostics: [{ code: "unsupported_mode", severity: "error", message }] };
|
|
317
384
|
}
|
|
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
385
|
const effectiveCapabilityCeiling = intersectSubagentCapabilityCeilings(input.capabilityCeiling, input.inheritedCapabilityCeiling);
|
|
332
386
|
const restrictionMessage = capabilityCeilingAgentRestrictionMessage(agent.name, effectiveCapabilityCeiling);
|
|
333
387
|
if (restrictionMessage) return { ok: false, code: "restricted_agent", message: restrictionMessage, diagnostics };
|
|
@@ -339,6 +393,7 @@ export async function resolveSubagentLaunchContract(input: SubagentLaunchContrac
|
|
|
339
393
|
...(input.outputMode !== undefined ? { outputMode: input.outputMode } : {}),
|
|
340
394
|
...(skillInput !== undefined ? { skills: skillInput } : {}),
|
|
341
395
|
...(input.model !== undefined ? { model: input.model } : {}),
|
|
396
|
+
...(input.outputSchema !== undefined ? { outputSchema: input.outputSchema } : {}),
|
|
342
397
|
});
|
|
343
398
|
const requestedSkills = behavior.skills === false ? [] : behavior.skills;
|
|
344
399
|
const resolvedSkills = resolveSkillsWithFallback(
|
|
@@ -354,6 +409,9 @@ export async function resolveSubagentLaunchContract(input: SubagentLaunchContrac
|
|
|
354
409
|
if (resolvedSkills.missing.length > 0) diagnostics.push({ code: "missing_skill", severity: "error", message: `Missing skills: ${resolvedSkills.missing.join(", ")}` });
|
|
355
410
|
|
|
356
411
|
const externalRunner = agent.runner?.type === "external-cli" || agent.runner?.type === "external-job";
|
|
412
|
+
if (externalRunner && behavior.outputSchema) {
|
|
413
|
+
return { ok: false, code: "unsupported_mode", message: `Agent '${agent.name}' uses runner.type='${agent.runner?.type}' and does not support: structured output.`, diagnostics };
|
|
414
|
+
}
|
|
357
415
|
const availableModels = normalizeAvailableModels(input.availableModels);
|
|
358
416
|
const preferredProvider = agent.modelProvider ?? input.preferredProvider ?? input.parentModel?.provider;
|
|
359
417
|
const modelScopes = resolveModelScopesForAgent(discovered.modelScope, agent.name, input.parentModel);
|
|
@@ -370,19 +428,14 @@ export async function resolveSubagentLaunchContract(input: SubagentLaunchContrac
|
|
|
370
428
|
input.thinkingCeiling,
|
|
371
429
|
input.inheritedThinkingCeiling,
|
|
372
430
|
);
|
|
373
|
-
const model = externalRunner ? undefined : applyThinkingSuffix(primaryModel,
|
|
374
|
-
const modelCandidates = externalRunner
|
|
375
|
-
? []
|
|
376
|
-
: buildModelCandidates(primaryModel, agent.fallbackModels, availableModels, preferredProvider, {
|
|
431
|
+
const model = externalRunner ? undefined : applyThinkingSuffix(resolveModelSelection(primaryModel, availableModels, preferredProvider, {
|
|
377
432
|
scope: modelScopes,
|
|
378
433
|
primaryModelFromParent: modelOrigin === "inherited" || inheritsParentModel(input.model, agent.model, input.parentModel),
|
|
379
434
|
origin: modelOrigin,
|
|
380
|
-
})
|
|
381
|
-
.map((candidate) => applyThinkingSuffix(candidate, effectiveThinkingConfig, input.thinking !== undefined) ?? candidate);
|
|
435
|
+
}).model, effectiveThinkingConfig, input.thinking !== undefined);
|
|
382
436
|
if (!externalRunner) {
|
|
383
437
|
try {
|
|
384
438
|
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
439
|
} catch (error) {
|
|
387
440
|
const message = error instanceof Error ? error.message : String(error);
|
|
388
441
|
diagnostics.push({ code: "thinking_ceiling", severity: "error", message });
|
|
@@ -392,6 +445,7 @@ export async function resolveSubagentLaunchContract(input: SubagentLaunchContrac
|
|
|
392
445
|
let toolPlan: PiLaunchToolPlan;
|
|
393
446
|
const permissionRules = resolvePermissionRules(loadConfig().permissions, agent.permissions);
|
|
394
447
|
const fast = input.fast ?? agent.fast;
|
|
448
|
+
const requiredExtensions = externalRunner ? [] : resolveRequiredChildExtensions(input.parentSessionId);
|
|
395
449
|
try {
|
|
396
450
|
toolPlan = resolvePiLaunchToolPlan({
|
|
397
451
|
tools: agent.tools,
|
|
@@ -399,18 +453,19 @@ export async function resolveSubagentLaunchContract(input: SubagentLaunchContrac
|
|
|
399
453
|
allowNestedSubagents: agent.allowNestedSubagents,
|
|
400
454
|
extensions: agent.extensions,
|
|
401
455
|
subagentOnlyExtensions: agent.subagentOnlyExtensions,
|
|
456
|
+
requiredExtensions,
|
|
402
457
|
mcpDirectTools: agent.mcpDirectTools,
|
|
403
458
|
cwd: effectiveCwd,
|
|
404
459
|
requireReadTool: resolvedSkills.resolved.length > 0,
|
|
405
|
-
structuredOutput: Boolean(
|
|
460
|
+
structuredOutput: Boolean(behavior.outputSchema),
|
|
406
461
|
fast,
|
|
407
462
|
model,
|
|
408
|
-
modelCandidates,
|
|
409
463
|
capabilityCeiling: effectiveCapabilityCeiling,
|
|
410
464
|
agentName: agent.name,
|
|
411
465
|
permissionRules,
|
|
412
466
|
sandbox: agent.sandbox,
|
|
413
467
|
permissionProfile: agent.permissionProfile,
|
|
468
|
+
hostAvailableBuiltins: input.hostAvailableBuiltins,
|
|
414
469
|
});
|
|
415
470
|
} catch (error) {
|
|
416
471
|
const message = error instanceof Error ? error.message : String(error);
|
|
@@ -422,7 +477,10 @@ export async function resolveSubagentLaunchContract(input: SubagentLaunchContrac
|
|
|
422
477
|
const artifactsDir = artifactsEnabled ? getArtifactsDir(input.parentSessionFile ?? null, effectiveCwd, input.artifactDir) : undefined;
|
|
423
478
|
const artifactPaths = artifactsDir ? getArtifactPaths(artifactsDir, runId, agent.name, 0) : undefined;
|
|
424
479
|
const outputPath = resolveSingleOutputPath(behavior.output, effectiveCwd, effectiveCwd, artifactsDir ? path.join(artifactsDir, "outputs", runId) : undefined);
|
|
425
|
-
|
|
480
|
+
// An explicit sessionDir is a root keyed by the child run id, matching the
|
|
481
|
+
// sibling sessionRoot derivation; hosts omitting runId get the documented
|
|
482
|
+
// deterministic "preflight" placeholder.
|
|
483
|
+
const sessionRoot = input.sessionDir ? path.join(path.resolve(input.sessionDir), runId) : input.sessionRoot ? path.join(path.resolve(input.sessionRoot), runId) : undefined;
|
|
426
484
|
const sessionDir = sessionRoot ? path.join(sessionRoot, "run-0") : undefined;
|
|
427
485
|
const lifecycleAsyncDir = input.nestedRootRunId
|
|
428
486
|
? path.join(TEMP_ROOT_DIR, "nested-subagent-runs", input.nestedRootRunId, runId)
|
|
@@ -437,17 +495,25 @@ export async function resolveSubagentLaunchContract(input: SubagentLaunchContrac
|
|
|
437
495
|
if (resolvedSkills.missing.length > 0) {
|
|
438
496
|
return { ok: false, code: "missing_skill", message: `Missing skills: ${resolvedSkills.missing.join(", ")}`, diagnostics };
|
|
439
497
|
}
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
498
|
+
const effectiveThinking = resolveEffectiveThinking(model, effectiveThinkingConfig);
|
|
499
|
+
const binding = resolveLaunchBinding({
|
|
500
|
+
agent,
|
|
501
|
+
task: input.task ?? "",
|
|
502
|
+
model,
|
|
503
|
+
...(fast !== undefined ? { fast } : {}),
|
|
504
|
+
...(effectiveThinking ? { thinking: effectiveThinking } : {}),
|
|
505
|
+
...(agent.sandbox ? { sandbox: agent.sandbox } : {}),
|
|
506
|
+
...(agent.permissionProfile ? { permissionProfile: agent.permissionProfile } : {}),
|
|
507
|
+
systemPrompt: buildEffectiveSystemPrompt({ agent, resolvedSkills: resolvedSkills.resolved, cwd: effectiveCwd, ...(outputPath ? { outputPath } : {}) }),
|
|
508
|
+
skills: requestedSkills,
|
|
509
|
+
toolPlan,
|
|
510
|
+
...(outputPath ? { outputPath } : {}),
|
|
511
|
+
outputMode: behavior.outputMode,
|
|
512
|
+
...(behavior.outputSchema ? { structuredOutputSchema: behavior.outputSchema } : {}),
|
|
513
|
+
...(extensionBindings ? { extensionBindings } : {}),
|
|
514
|
+
});
|
|
448
515
|
const candidates = candidateList(input.agent, agent, discovery.all);
|
|
449
516
|
const shadowedCandidates = candidates.filter((candidate) => !candidate.selected);
|
|
450
|
-
const definitionDigest = agentDefinitionDigest(agent);
|
|
451
517
|
const contractBase: Omit<SubagentLaunchContract, "digest"> = {
|
|
452
518
|
version: SUBAGENT_LAUNCH_CONTRACT_VERSION,
|
|
453
519
|
runId,
|
|
@@ -458,13 +524,12 @@ export async function resolveSubagentLaunchContract(input: SubagentLaunchContrac
|
|
|
458
524
|
source: agent.source,
|
|
459
525
|
filePath: agent.filePath,
|
|
460
526
|
definitionProjectionVersion: AGENT_DEFINITION_PROJECTION_VERSION,
|
|
461
|
-
definitionDigest,
|
|
527
|
+
definitionDigest: binding.definitionDigest,
|
|
462
528
|
shadowedCandidates,
|
|
463
529
|
},
|
|
464
530
|
context,
|
|
465
531
|
...(model ? { model } : {}),
|
|
466
|
-
|
|
467
|
-
...(resolveEffectiveThinking(model, effectiveThinkingConfig) ? { thinking: resolveEffectiveThinking(model, effectiveThinkingConfig) } : {}),
|
|
532
|
+
...(effectiveThinking ? { thinking: effectiveThinking } : {}),
|
|
468
533
|
...(thinkingCeiling ? { thinkingCeiling } : {}),
|
|
469
534
|
...(agent.sandbox ? { sandbox: agent.sandbox } : {}),
|
|
470
535
|
...(agent.permissionProfile ? { permissionProfile: agent.permissionProfile } : {}),
|
|
@@ -490,12 +555,15 @@ export async function resolveSubagentLaunchContract(input: SubagentLaunchContrac
|
|
|
490
555
|
toolExtensionPaths: toolPlan.toolExtensionPaths,
|
|
491
556
|
runtimeExtensions: toolPlan.runtimeExtensions,
|
|
492
557
|
configuredExtensions: toolPlan.configuredExtensions,
|
|
493
|
-
|
|
558
|
+
requiredExtensionIds: toolPlan.requiredExtensions.map(({ id }) => id),
|
|
559
|
+
// Required paths are private launch authority; preflight exposes their safe IDs above.
|
|
560
|
+
extensionArgs: toolPlan.extensionArgs.filter((extensionPath) => !requiredExtensions.some(({ path }) => path === extensionPath)),
|
|
494
561
|
disableAmbientExtensions: toolPlan.disableAmbientExtensions,
|
|
495
562
|
fanoutAuthorized: toolPlan.fanoutAuthorized,
|
|
496
563
|
...(toolPlan.capabilityCeiling ? { capabilityCeiling: toolPlan.capabilityCeiling } : {}),
|
|
497
564
|
...(toolPlan.capabilityAudit ? { capabilityAudit: toolPlan.capabilityAudit } : {}),
|
|
498
565
|
},
|
|
566
|
+
intercomBridge: bridge.active && bridge.mode !== "off" ? { active: true, mode: bridge.mode } : { active: false, mode: bridge.mode },
|
|
499
567
|
roots: {
|
|
500
568
|
cwd: effectiveCwd,
|
|
501
569
|
...(sessionRoot ? { sessionRoot } : {}),
|
|
@@ -517,30 +585,7 @@ export async function resolveSubagentLaunchContract(input: SubagentLaunchContrac
|
|
|
517
585
|
packageVersion: packageVersion(),
|
|
518
586
|
},
|
|
519
587
|
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
|
-
}),
|
|
588
|
+
launchContractDigest: binding.launchContractDigest,
|
|
544
589
|
};
|
|
545
590
|
return { ok: true, contract: { ...contractBase, digest: digestContract(contractBase) } };
|
|
546
591
|
}
|
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";
|