pi-subagents 0.40.0 → 0.42.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 +97 -0
- package/README.md +54 -1879
- package/agents/oracle.md +1 -0
- package/inspector-runner.mjs +11 -0
- package/package.json +13 -5
- package/prompts/parallel-context-build.md +1 -1
- package/prompts/parallel-handoff-plan.md +1 -1
- package/prompts/review-loop.md +1 -1
- package/skills/pi-subagents/SKILL.md +9 -7
- package/skills/pi-subagents/references/constraints-and-recipes.md +24 -32
- package/skills/pi-subagents/references/execution-controls.md +99 -97
- package/skills/pi-subagents/references/management-authoring-rpc.md +2 -2
- package/skills/pi-subagents/references/prompting-and-roles.md +23 -30
- package/src/agents/agent-management.ts +155 -65
- package/src/agents/agent-serializer.ts +19 -0
- package/src/agents/agents.ts +154 -71
- package/src/agents/chain-serializer.ts +10 -7
- package/src/agents/frontmatter.ts +5 -3
- package/src/agents/identity.ts +1 -1
- package/src/agents/proactive-skills.ts +13 -10
- package/src/agents/skills.ts +23 -6
- package/src/api/control-channel.ts +4 -0
- package/src/api/delegation.ts +26 -194
- package/src/api/external-runs.ts +129 -0
- package/src/api/intercom-bridge.ts +3 -0
- package/src/api/pi-args.ts +5 -0
- package/src/api/preflight.ts +3 -3
- package/src/api/shared-types.ts +19 -0
- package/src/extension/config.ts +10 -0
- package/src/extension/control-notices.ts +5 -39
- package/src/extension/doctor.ts +10 -9
- package/src/extension/fanout-child.ts +7 -4
- package/src/extension/index.ts +232 -68
- package/src/extension/rpc.ts +18 -12
- package/src/extension/schemas.ts +48 -37
- package/src/extension/tool-description.ts +36 -86
- package/src/inspectors/herdr/actions.ts +229 -0
- package/src/inspectors/herdr/client.ts +130 -0
- package/src/inspectors/herdr/inspector-runner.ts +141 -0
- package/src/inspectors/herdr/project-panes.ts +154 -0
- package/src/integrations/herdr-status.ts +330 -0
- package/src/intercom/intercom-bridge.ts +3 -2
- package/src/intercom/result-intercom.ts +5 -1
- package/src/missions/actions.ts +374 -0
- package/src/missions/lifecycle.ts +314 -0
- package/src/missions/store.ts +442 -0
- package/src/missions/types.ts +135 -0
- package/src/policy/authority.ts +46 -0
- package/src/profiles/profiles.ts +29 -3
- package/src/runs/background/async-execution.ts +110 -50
- package/src/runs/background/async-job-tracker.ts +27 -4
- package/src/runs/background/async-resume.ts +6 -6
- package/src/runs/background/async-status.ts +29 -1
- package/src/runs/background/auto-drain.ts +3 -3
- package/src/runs/background/chain-append.ts +3 -2
- package/src/runs/background/control-channel.ts +9 -7
- package/src/runs/background/fleet-view.ts +3 -4
- package/src/runs/background/notify.ts +2 -1
- package/src/runs/background/process-terminal.ts +5 -5
- package/src/runs/background/result-watcher.ts +13 -5
- package/src/runs/background/run-id-resolver.ts +3 -3
- package/src/runs/background/run-status.ts +35 -8
- package/src/runs/background/scheduled-runs.ts +602 -375
- package/src/runs/background/stale-run-reconciler.ts +3 -3
- package/src/runs/background/subagent-runner.ts +608 -445
- package/src/runs/background/subagent-wait.ts +50 -9
- package/src/runs/background/wait-subscriptions.ts +253 -0
- package/src/runs/background/wait-tool.ts +12 -4
- package/src/runs/foreground/async-steering-action.ts +3 -3
- package/src/runs/foreground/chain-clarify.ts +8 -4
- package/src/runs/foreground/chain-execution.ts +56 -30
- package/src/runs/foreground/execution.ts +34 -9
- package/src/runs/foreground/subagent-executor.ts +1036 -274
- package/src/runs/shared/acceptance.ts +28 -6
- package/src/runs/shared/child-protocol.ts +302 -22
- package/src/runs/shared/dynamic-fanout.ts +1 -1
- package/src/runs/shared/external-cli-runner.ts +130 -0
- package/src/runs/shared/long-running-guard.ts +42 -1
- package/src/runs/shared/mcp-direct-tool-allowlist.ts +2 -0
- package/src/runs/shared/nested-events.ts +59 -5
- package/src/runs/shared/nested-render.ts +9 -4
- package/src/runs/shared/parallel-handoff.ts +86 -2
- package/src/runs/shared/parallel-utils.ts +11 -2
- package/src/runs/shared/permissions.ts +95 -0
- package/src/runs/shared/pi-args.ts +468 -109
- package/src/runs/shared/pi-spawn.ts +11 -1
- package/src/runs/shared/run-history.ts +1 -1
- package/src/runs/shared/subagent-prompt-runtime.ts +36 -5
- package/src/runs/shared/subagent-startup-retry.ts +5 -2
- package/src/runs/shared/turn-budget.ts +6 -6
- package/src/runs/shared/worktree.ts +122 -12
- package/src/shared/accessible-dir.ts +29 -7
- package/src/shared/artifacts.ts +143 -1
- package/src/shared/fork-context.ts +3 -2
- package/src/shared/launch-contract.ts +1 -0
- package/src/shared/settings.ts +10 -0
- package/src/shared/types.ts +156 -14
- package/src/shared/utils.ts +8 -6
- package/src/slash/delegation-adapters.ts +32 -194
- package/src/slash/delegation-request.ts +43 -126
- package/src/slash/prompt-template-bridge.ts +158 -205
- package/src/slash/prompt-workflows.ts +21 -57
- package/src/slash/slash-bridge.ts +14 -0
- package/src/slash/slash-commands.ts +31 -632
- package/src/slash/subagents-admin.ts +18 -14
- package/src/tui/fleet-status.ts +156 -21
- package/src/tui/fleet-transcript.ts +110 -5
- package/src/tui/fleet.ts +57 -25
- package/src/tui/render.ts +368 -152
- package/src/types/pi-runtime-compat.d.ts +8 -0
- package/src/watchdog/lsp-diagnostics.ts +12 -7
- package/src/watchdog/model-selection.ts +2 -2
- package/src/watchdog/permission-arbiter.ts +145 -0
- package/src/watchdog/register-child.ts +1 -1
- package/src/watchdog/register-main.ts +1 -1
- package/src/watchdog/review.ts +4 -1
- package/src/watchdog/runtime.ts +3 -2
- package/src/workflows/chat-progress.ts +140 -0
- package/src/workflows/scripted-workflow.ts +415 -0
- package/agents/advisor.md +0 -73
- package/src/extension/chain-validation.ts +0 -181
|
@@ -55,6 +55,7 @@ import { evaluateCompletionMutationGuard } from "../shared/completion-guard.ts";
|
|
|
55
55
|
import { getPiSpawnCommand } from "../shared/pi-spawn.ts";
|
|
56
56
|
import { createJsonlWriter } from "../../shared/jsonl-writer.ts";
|
|
57
57
|
import { attachPostExitStdioGuard, trySignalChild } from "../../shared/post-exit-stdio-guard.ts";
|
|
58
|
+
import { resolvePermissionRules } from "../shared/permissions.ts";
|
|
58
59
|
import { applyThinkingSuffix, buildPiArgs, cleanupTempDir, projectLaunchResolvedChildExtensions, resolvePiLaunchToolPlan } from "../shared/pi-args.ts";
|
|
59
60
|
import { readRuntimeAcknowledgedExtensions } from "../shared/runtime-acknowledged-extensions.ts";
|
|
60
61
|
import { assertAgentAllowedByCapabilityCeiling, decodeSubagentCapabilityCeiling, intersectSubagentCapabilityCeilings, resolveCurrentSubagentCapabilityCeiling, SUBAGENT_CAPABILITY_CEILING_ENV } from "../shared/capability-ceiling.ts";
|
|
@@ -86,13 +87,13 @@ import {
|
|
|
86
87
|
shouldEscalateMutatingFailures,
|
|
87
88
|
summarizeRecentMutatingFailures,
|
|
88
89
|
} from "../shared/long-running-guard.ts";
|
|
89
|
-
import { acceptanceFailureMessage, buildSkippedAcceptanceLedger, evaluateAcceptance, formatAcceptancePrompt, resolveEffectiveAcceptance, stripAcceptanceReport } from "../shared/acceptance.ts";
|
|
90
|
+
import { acceptanceFailureMessage, buildSkippedAcceptanceLedger, evaluateAcceptance, formatAcceptancePrompt, resolveEffectiveAcceptance, stripAcceptanceReport, validateAcceptanceInput } from "../shared/acceptance.ts";
|
|
90
91
|
import { attachContractProjections, isAgentContractV1 } from "../shared/agent-contract.ts";
|
|
91
92
|
import { appendTurnBudgetSystemPrompt, formatTurnBudgetOutput, initialTurnBudgetState, turnBudgetDecision, turnBudgetDeferredNote, turnBudgetDeferredState, turnBudgetExceededMessage, turnBudgetSoftNote, turnBudgetState } from "../shared/turn-budget.ts";
|
|
92
93
|
import { initialToolBudgetState, toolBudgetState } from "../shared/tool-budget.ts";
|
|
93
94
|
import { resolveWatchdogConfig } from "../../watchdog/settings.ts";
|
|
94
95
|
import { agentDefinitionDigest, launchBindingDigest } from "../../shared/launch-contract.ts";
|
|
95
|
-
import { createBoundedByteTail, createBoundedLineReader, formatProtocolOutputLimit, MAX_CHILD_STDERR_BYTES, projectChildLifecycle, type ChildLifecycleAction, type ProtocolOutputLimit } from "../shared/child-protocol.ts";
|
|
96
|
+
import { createBoundedByteTail, createBoundedLineReader, formatProtocolOutputLimit, MAX_CHILD_STDERR_BYTES, PI_AGGREGATE_EVENT_PROJECTOR, projectChildLifecycle, type ChildLifecycleAction, type ProtocolOutputLimit } from "../shared/child-protocol.ts";
|
|
96
97
|
import {
|
|
97
98
|
acceptChildWatchdogEvent,
|
|
98
99
|
childWatchdogIsActive,
|
|
@@ -302,6 +303,10 @@ async function runSingleAttempt(
|
|
|
302
303
|
childIndex: options.index ?? 0,
|
|
303
304
|
})
|
|
304
305
|
: undefined;
|
|
306
|
+
const permissionRules = resolvePermissionRules(options.permissions, agent.permissions);
|
|
307
|
+
const permissionAuditPath = permissionRules && options.artifactsDir
|
|
308
|
+
? path.join(options.artifactsDir, "permission-audit", `${options.runId}-${options.index ?? 0}.jsonl`)
|
|
309
|
+
: undefined;
|
|
305
310
|
const { args, env: sharedEnv, tempDir, toolDiagnosticPath, runtimeAcknowledgedExtensionsPath, capabilityAudit } = buildPiArgs({
|
|
306
311
|
baseArgs: ["--mode", "json", "-p"],
|
|
307
312
|
task,
|
|
@@ -334,6 +339,8 @@ async function runSingleAttempt(
|
|
|
334
339
|
structuredOutput: options.structuredOutput,
|
|
335
340
|
toolBudget: options.toolBudget,
|
|
336
341
|
allowZeroToolBudget: options.allowZeroToolBudget,
|
|
342
|
+
permissionRules,
|
|
343
|
+
permissionAuditPath,
|
|
337
344
|
childWatchdog,
|
|
338
345
|
waitToolEnabled: options.waitToolEnabled,
|
|
339
346
|
capabilityCeiling: options.capabilityCeiling,
|
|
@@ -977,14 +984,14 @@ async function runSingleAttempt(
|
|
|
977
984
|
}
|
|
978
985
|
};
|
|
979
986
|
|
|
980
|
-
|
|
987
|
+
fireUpdate();
|
|
988
|
+
if (controlConfig.enabled || options.onUpdate) {
|
|
981
989
|
activityTimer = setInterval(() => {
|
|
982
|
-
if (processClosed || lifecycleFinished)
|
|
983
|
-
|
|
984
|
-
if (updateActivityState(now)) {
|
|
985
|
-
progress.durationMs = now - startTime;
|
|
986
|
-
fireUpdate();
|
|
990
|
+
if (processClosed || lifecycleFinished) {
|
|
991
|
+
return;
|
|
987
992
|
}
|
|
993
|
+
updateActivityState(Date.now());
|
|
994
|
+
fireUpdate();
|
|
988
995
|
}, 1000);
|
|
989
996
|
activityTimer.unref?.();
|
|
990
997
|
}
|
|
@@ -1031,7 +1038,11 @@ async function runSingleAttempt(
|
|
|
1031
1038
|
protocolHardKillTimer.unref?.();
|
|
1032
1039
|
}
|
|
1033
1040
|
};
|
|
1034
|
-
const stdoutReader = createBoundedLineReader({
|
|
1041
|
+
const stdoutReader = createBoundedLineReader({
|
|
1042
|
+
oversizedLineProjector: PI_AGGREGATE_EVENT_PROJECTOR,
|
|
1043
|
+
onLine: processLine,
|
|
1044
|
+
onLimit: failProtocol,
|
|
1045
|
+
});
|
|
1035
1046
|
const stderrReader = createBoundedLineReader({
|
|
1036
1047
|
stream: "stderr",
|
|
1037
1048
|
maxPendingLineBytes: MAX_CHILD_STDERR_BYTES,
|
|
@@ -1229,6 +1240,7 @@ async function runSingleAttempt(
|
|
|
1229
1240
|
|
|
1230
1241
|
const acceptanceOutput = getFinalOutput(result.messages ?? []);
|
|
1231
1242
|
let fullOutput = stripAcceptanceReport(acceptanceOutput);
|
|
1243
|
+
if (!fullOutput.trim() && result.structuredOutput !== undefined) fullOutput = JSON.stringify(result.structuredOutput, null, 2);
|
|
1232
1244
|
result.outputState = fullOutput.trim() || result.structuredOutput !== undefined ? "present" : "absent";
|
|
1233
1245
|
if (result.timedOut) {
|
|
1234
1246
|
const timeoutMessage = formatTimeoutMessage(options.timeoutMs ?? 0);
|
|
@@ -1346,6 +1358,7 @@ async function runSyncCompletion(
|
|
|
1346
1358
|
assertAgentAllowedByCapabilityCeiling(agent.name, options.capabilityCeiling);
|
|
1347
1359
|
} catch (error) {
|
|
1348
1360
|
return withRunContext({
|
|
1361
|
+
index: options.index ?? 0,
|
|
1349
1362
|
agent: agent.name,
|
|
1350
1363
|
task,
|
|
1351
1364
|
exitCode: 1,
|
|
@@ -1355,6 +1368,18 @@ async function runSyncCompletion(
|
|
|
1355
1368
|
...(options.capabilityCeiling ? { capabilityCeiling: options.capabilityCeiling } : {}),
|
|
1356
1369
|
}, options.context);
|
|
1357
1370
|
}
|
|
1371
|
+
const acceptanceErrors = validateAcceptanceInput(options.acceptance);
|
|
1372
|
+
if (acceptanceErrors.length > 0) {
|
|
1373
|
+
return withRunContext({
|
|
1374
|
+
index: options.index ?? 0,
|
|
1375
|
+
agent: agentName,
|
|
1376
|
+
task,
|
|
1377
|
+
exitCode: 1,
|
|
1378
|
+
messages: [],
|
|
1379
|
+
usage: emptyUsage(),
|
|
1380
|
+
error: acceptanceErrors.join(" "),
|
|
1381
|
+
}, options.context);
|
|
1382
|
+
}
|
|
1358
1383
|
const outputModeValidationError = validateFileOnlyOutputMode(options.outputMode, options.outputPath, `Single run (${agentName})`);
|
|
1359
1384
|
if (outputModeValidationError) {
|
|
1360
1385
|
return withRunContext({
|