@narumitw/pi-subagents 0.53.0 → 0.54.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/README.md +75 -6
- package/package.json +1 -1
- package/src/agents/built-ins.ts +124 -0
- package/src/agents/catalog.ts +224 -0
- package/src/agents/discovery.ts +249 -0
- package/src/agents/types.ts +98 -0
- package/src/agents.ts +47 -670
- package/src/auto-transport.ts +2 -1
- package/src/automation.ts +7 -2
- package/src/capability-router.ts +1 -1
- package/src/completion-delivery.ts +2 -3
- package/src/config-status.ts +2 -2
- package/src/config-ui.ts +8 -8
- package/src/consult-resources.ts +1 -1
- package/src/consult.ts +9 -7
- package/src/create-stateful-transport.ts +2 -1
- package/src/cwd-policy.ts +1 -1
- package/src/execution/budget.ts +56 -0
- package/src/execution/runtime-policy.ts +19 -0
- package/src/execution-plan.ts +1 -1
- package/src/execution-profiles.ts +1 -1
- package/src/execution-ui.ts +1 -1
- package/src/execution.ts +269 -100
- package/src/in-process-transport.ts +3 -2
- package/src/inspect.ts +35 -8
- package/src/limits.ts +1 -0
- package/src/orchestration-metrics.ts +12 -5
- package/src/panel-execution.ts +1 -1
- package/src/panel-planning.ts +1 -1
- package/src/params.ts +3 -1
- package/src/persistence.ts +1 -1
- package/src/registry-types.ts +1 -1
- package/src/registry.ts +1 -1
- package/src/render.ts +1 -1
- package/src/retained-semantic-state.ts +1 -1
- package/src/rpc-transport-metadata.ts +1 -1
- package/src/rpc-transport.ts +2 -1
- package/src/runner.ts +6 -1
- package/src/settings/inspection.ts +275 -0
- package/src/settings/schema.ts +186 -0
- package/src/settings.ts +72 -420
- package/src/spawn-idempotency.ts +1 -1
- package/src/stateful-agent-view.ts +87 -0
- package/src/stateful-config.ts +1 -1
- package/src/stateful-guidance.ts +1 -1
- package/src/stateful-limits.ts +1 -1
- package/src/stateful-prompt.ts +2 -2
- package/src/stateful-safety.ts +2 -1
- package/src/stateful.ts +23 -103
- package/src/subagents.ts +8 -9
- package/src/subprocess-transport.ts +2 -6
- package/src/transport-types.ts +1 -1
- package/src/transport-ui.ts +1 -1
- package/src/verification-harness.ts +516 -0
- package/src/verification-receipt.ts +275 -0
- package/src/verified-execution-benchmark.ts +86 -0
- package/src/verified-execution-contract.ts +219 -0
- package/src/work-item-ledger.ts +510 -37
- package/src/work-item-persistence.ts +31 -0
- package/src/workflow-completion-controller.ts +397 -0
- package/src/workflow-plan-compiler.ts +1 -1
- package/src/workflow-plan-patch.ts +1 -1
- package/src/workflow-planning.ts +11 -1
- package/src/workflow-ui.ts +1 -1
package/src/auto-transport.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { discoverAgents
|
|
1
|
+
import { discoverAgents } from "./agents/discovery.js";
|
|
2
|
+
import type { SubagentSettings } from "./agents/types.js";
|
|
2
3
|
import type { ManagedAgent, TurnOutcome } from "./registry.js";
|
|
3
4
|
import { isWriteCapable } from "./stateful-safety.js";
|
|
4
5
|
import type { SubagentTransport } from "./transport.js";
|
package/src/automation.ts
CHANGED
|
@@ -9,7 +9,9 @@ import {
|
|
|
9
9
|
} from "@earendil-works/pi-coding-agent";
|
|
10
10
|
import { Text } from "@earendil-works/pi-tui";
|
|
11
11
|
import { type Static, Type } from "typebox";
|
|
12
|
-
import {
|
|
12
|
+
import { getBuiltInAgent } from "./agents/built-ins.js";
|
|
13
|
+
import { discoverAgents } from "./agents/discovery.js";
|
|
14
|
+
import type { SubagentSettings } from "./agents/types.js";
|
|
13
15
|
import {
|
|
14
16
|
AutomationRequestSchema,
|
|
15
17
|
parseAutomationRequest,
|
|
@@ -39,7 +41,10 @@ import {
|
|
|
39
41
|
type SubagentDetails,
|
|
40
42
|
} from "./runner.js";
|
|
41
43
|
import { boundedPrivateText } from "./safe-text.js";
|
|
42
|
-
import {
|
|
44
|
+
import {
|
|
45
|
+
DEFAULT_DELEGATION_CWD_POLICY,
|
|
46
|
+
resolveBlockingMaxParallelTasks,
|
|
47
|
+
} from "./settings/inspection.js";
|
|
43
48
|
import {
|
|
44
49
|
type CompiledWorkflowPlan,
|
|
45
50
|
compileWorkflowPlan,
|
package/src/capability-router.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
2
|
-
import type { CompletionDelivery } from "./agents.js";
|
|
2
|
+
import type { CompletionDelivery } from "./agents/types.js";
|
|
3
3
|
import { redactPrivateText } from "./context.js";
|
|
4
|
-
import { DEFAULT_MAX_CONTEXT_BYTES, truncateUtf8 } from "./limits.js";
|
|
4
|
+
import { DEFAULT_MAX_CONTEXT_BYTES, MAX_TOOL_MESSAGE_BYTES, truncateUtf8 } from "./limits.js";
|
|
5
5
|
import type { AgentTurnCompletion, ManagedAgent } from "./registry.js";
|
|
6
6
|
import { safeTerminalText } from "./safe-text.js";
|
|
7
7
|
import { PI_SUBAGENTS_RPC_PROTOCOL } from "./transport-types.js";
|
|
8
8
|
|
|
9
|
-
const MAX_TOOL_MESSAGE_BYTES = 2 * 1024;
|
|
10
9
|
const MAX_COMPLETION_ERROR_BYTES = 512;
|
|
11
10
|
const MAX_COMPLETIONS_PER_MESSAGE = 16;
|
|
12
11
|
const COMPLETION_BATCH_DELAY_MS = 10;
|
package/src/config-status.ts
CHANGED
|
@@ -4,11 +4,11 @@ import type {
|
|
|
4
4
|
ConsultationCwdPolicy,
|
|
5
5
|
ConsultResourcePolicy,
|
|
6
6
|
DelegationCwdPolicy,
|
|
7
|
-
} from "./agents.js";
|
|
7
|
+
} from "./agents/types.js";
|
|
8
8
|
import type { SubagentSettingsRuntime } from "./config-ui.js";
|
|
9
9
|
import { safeTerminalLine as safeTerminalText } from "./safe-text.js";
|
|
10
|
+
import type { DelegationWorkflow } from "./settings/inspection.js";
|
|
10
11
|
import {
|
|
11
|
-
type DelegationWorkflow,
|
|
12
12
|
inspectBlockingParallelLimitSettings,
|
|
13
13
|
inspectCompletionDeliverySettings,
|
|
14
14
|
inspectConsultResourceSettings,
|
package/src/config-ui.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { ExtensionAPI, ExtensionCommandContext } from "@earendil-works/pi-coding-agent";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
} from "./agents.js";
|
|
2
|
+
import { discoverAgents } from "./agents/discovery.js";
|
|
3
|
+
import type {
|
|
4
|
+
CompletionDelivery,
|
|
5
|
+
ConsultationCwdPolicy,
|
|
6
|
+
ConsultResourcePolicy,
|
|
7
|
+
DelegationCwdPolicy,
|
|
8
|
+
} from "./agents/types.js";
|
|
9
9
|
import {
|
|
10
10
|
completionLabel,
|
|
11
11
|
consultationCwdLabel,
|
|
@@ -38,8 +38,8 @@ import {
|
|
|
38
38
|
} from "./parallel-limit-ui.js";
|
|
39
39
|
import type { ManagedAgent } from "./registry.js";
|
|
40
40
|
import { safeTerminalLine as safeTerminalText } from "./safe-text.js";
|
|
41
|
+
import type { DelegationWorkflow } from "./settings/inspection.js";
|
|
41
42
|
import {
|
|
42
|
-
type DelegationWorkflow,
|
|
43
43
|
hasOwn,
|
|
44
44
|
inspectBlockingParallelLimitSettings,
|
|
45
45
|
inspectCompletionDeliverySettings,
|
package/src/consult-resources.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ConsultResourcePolicy } from "./agents.js";
|
|
1
|
+
import type { ConsultResourcePolicy } from "./agents/types.js";
|
|
2
2
|
import { DEFAULT_MAX_CONTEXT_BYTES, truncateUtf8 } from "./limits.js";
|
|
3
3
|
import { resolvePiPromptResources } from "./prompt-resources.js";
|
|
4
4
|
import type { ChildLaunchPolicy } from "./runner.js";
|
package/src/consult.ts
CHANGED
|
@@ -8,17 +8,16 @@ import {
|
|
|
8
8
|
type ToolDefinition,
|
|
9
9
|
} from "@earendil-works/pi-coding-agent";
|
|
10
10
|
import { type Static, Type } from "typebox";
|
|
11
|
+
import { DEFAULT_AGENT_CATALOG_MAX_ITEMS } from "./agents/catalog.js";
|
|
12
|
+
import { type AgentDiscoveryResult, discoverAgents } from "./agents/discovery.js";
|
|
11
13
|
import {
|
|
12
14
|
type AgentConfig,
|
|
13
|
-
type AgentDiscoveryResult,
|
|
14
15
|
type AgentScope,
|
|
15
16
|
type ConsultResourcePolicy,
|
|
16
|
-
DEFAULT_AGENT_CATALOG_MAX_ITEMS,
|
|
17
|
-
discoverAgents,
|
|
18
17
|
isThinkingLevel,
|
|
19
18
|
type SubagentSettings,
|
|
20
19
|
THINKING_LEVELS,
|
|
21
|
-
} from "./agents.js";
|
|
20
|
+
} from "./agents/types.js";
|
|
22
21
|
import { resolveConsultTools } from "./consult-policy.js";
|
|
23
22
|
import { renderConsultCall, renderConsultResult } from "./consult-render.js";
|
|
24
23
|
import { resolveConsultResourceLaunchPolicy } from "./consult-resources.js";
|
|
@@ -27,7 +26,10 @@ import {
|
|
|
27
26
|
type ResolvedSubagentTarget,
|
|
28
27
|
resolveSubagentTarget,
|
|
29
28
|
} from "./cwd-policy.js";
|
|
30
|
-
import {
|
|
29
|
+
import {
|
|
30
|
+
assertSubagentDepthAllowed,
|
|
31
|
+
resolveDefaultSubagentTimeoutMs,
|
|
32
|
+
} from "./execution/runtime-policy.js";
|
|
31
33
|
import {
|
|
32
34
|
DEFAULT_MAX_CONTEXT_BYTES,
|
|
33
35
|
DEFAULT_MAX_STDERR_BYTES,
|
|
@@ -45,8 +47,8 @@ import { boundedPrivateText, boundText, safeDisplayPath, safeTerminalLine } from
|
|
|
45
47
|
import {
|
|
46
48
|
DEFAULT_CONSULT_RESOURCE_POLICY,
|
|
47
49
|
DEFAULT_CONSULTATION_CWD_POLICY,
|
|
48
|
-
|
|
49
|
-
} from "./settings.js";
|
|
50
|
+
} from "./settings/inspection.js";
|
|
51
|
+
import { resolveSubagentThinkingLevel } from "./settings.js";
|
|
50
52
|
|
|
51
53
|
const ConsultScopeSchema = StringEnum(["user", "project", "both"] as const, {
|
|
52
54
|
default: "user",
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ModelRegistry } from "@earendil-works/pi-coding-agent";
|
|
2
|
-
import { discoverAgents
|
|
2
|
+
import { discoverAgents } from "./agents/discovery.js";
|
|
3
|
+
import type { SubagentSettings, SubagentTransportKind } from "./agents/types.js";
|
|
3
4
|
import { AutoTransport } from "./auto-transport.js";
|
|
4
5
|
import {
|
|
5
6
|
type ChildSessionFactory,
|
package/src/cwd-policy.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as fs from "node:fs";
|
|
2
2
|
import * as path from "node:path";
|
|
3
3
|
import { getAgentDir, ProjectTrustStore } from "@earendil-works/pi-coding-agent";
|
|
4
|
-
import type { ConsultationCwdPolicy, DelegationCwdPolicy } from "./agents.js";
|
|
4
|
+
import type { ConsultationCwdPolicy, DelegationCwdPolicy } from "./agents/types.js";
|
|
5
5
|
import { safeTerminalLine } from "./safe-text.js";
|
|
6
6
|
|
|
7
7
|
export type TargetBoundary = "current-workspace" | "external";
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { AgentConfig } from "../agents/types.js";
|
|
2
|
+
import type { TurnLimits } from "../turn-budget.js";
|
|
3
|
+
|
|
4
|
+
export interface ExecutionBudget {
|
|
5
|
+
timeoutMs: number;
|
|
6
|
+
workTimeoutReason: "work_timeout" | "orchestration_timeout";
|
|
7
|
+
workTimeoutReportLimit: number;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function resolveConfiguredTimeout(
|
|
11
|
+
agents: readonly AgentConfig[],
|
|
12
|
+
agentName: string,
|
|
13
|
+
localTimeoutMs: number | undefined,
|
|
14
|
+
topLevelTimeoutMs: number | undefined,
|
|
15
|
+
defaultTimeoutMs: number,
|
|
16
|
+
): number {
|
|
17
|
+
return (
|
|
18
|
+
localTimeoutMs ??
|
|
19
|
+
topLevelTimeoutMs ??
|
|
20
|
+
agents.find((agent) => agent.name === agentName)?.timeoutMs ??
|
|
21
|
+
defaultTimeoutMs
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function mergeTurnLimits(local: TurnLimits | undefined, fallback: TurnLimits): TurnLimits {
|
|
26
|
+
return {
|
|
27
|
+
idleTimeoutMs: local?.idleTimeoutMs ?? fallback.idleTimeoutMs,
|
|
28
|
+
maxTurns: local?.maxTurns ?? fallback.maxTurns,
|
|
29
|
+
maxToolCalls: local?.maxToolCalls ?? fallback.maxToolCalls,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function calculateExecutionBudget(input: {
|
|
34
|
+
requestedTimeoutMs: number;
|
|
35
|
+
orchestrationDeadline?: number;
|
|
36
|
+
totalTimeoutMs?: number;
|
|
37
|
+
now: number;
|
|
38
|
+
}): ExecutionBudget | undefined {
|
|
39
|
+
if (input.orchestrationDeadline === undefined) {
|
|
40
|
+
return {
|
|
41
|
+
timeoutMs: input.requestedTimeoutMs,
|
|
42
|
+
workTimeoutReason: "work_timeout",
|
|
43
|
+
workTimeoutReportLimit: input.requestedTimeoutMs,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
const remaining = Math.floor(input.orchestrationDeadline - input.now);
|
|
47
|
+
if (remaining < 1) return undefined;
|
|
48
|
+
const orchestrationLimited = remaining < input.requestedTimeoutMs;
|
|
49
|
+
return {
|
|
50
|
+
timeoutMs: Math.min(input.requestedTimeoutMs, remaining),
|
|
51
|
+
workTimeoutReason: orchestrationLimited ? "orchestration_timeout" : "work_timeout",
|
|
52
|
+
workTimeoutReportLimit: orchestrationLimited
|
|
53
|
+
? Math.floor(input.totalTimeoutMs as number)
|
|
54
|
+
: input.requestedTimeoutMs,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export const FALLBACK_TIMEOUT_MS = 10 * 60 * 1000;
|
|
2
|
+
|
|
3
|
+
export function parsePositiveInteger(value: string | undefined): number | undefined {
|
|
4
|
+
if (!value) return undefined;
|
|
5
|
+
const parsed = Number.parseInt(value, 10);
|
|
6
|
+
return Number.isFinite(parsed) && parsed > 0 ? parsed : undefined;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function resolveDefaultSubagentTimeoutMs(): number {
|
|
10
|
+
return parsePositiveInteger(process.env.PI_SUBAGENT_TIMEOUT_MS) ?? FALLBACK_TIMEOUT_MS;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function assertSubagentDepthAllowed(): void {
|
|
14
|
+
const depth = Number.parseInt(process.env.PI_SUBAGENT_DEPTH ?? "0", 10) || 0;
|
|
15
|
+
const maxDepth = parsePositiveInteger(process.env.PI_SUBAGENT_MAX_DEPTH) ?? 1;
|
|
16
|
+
if (depth >= maxDepth) {
|
|
17
|
+
throw new Error(`Subagent recursion depth limit reached (${maxDepth})`);
|
|
18
|
+
}
|
|
19
|
+
}
|
package/src/execution-plan.ts
CHANGED
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
type AgentSource,
|
|
9
9
|
resolveAgentToolNames,
|
|
10
10
|
type SubagentThinkingLevel,
|
|
11
|
-
} from "./agents.js";
|
|
11
|
+
} from "./agents/types.js";
|
|
12
12
|
import type { TargetPolicyAudit } from "./cwd-policy.js";
|
|
13
13
|
import type { DelegationContract } from "./delegation-contract.js";
|
|
14
14
|
import type { SubagentResultFormat } from "./result-contract.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { SubagentThinkingLevel } from "./agents.js";
|
|
1
|
+
import type { SubagentThinkingLevel } from "./agents/types.js";
|
|
2
2
|
import { readSubagentSettings, updateAgentSettingsPatch } from "./settings.js";
|
|
3
3
|
|
|
4
4
|
export const EXECUTION_PROFILES = ["fast", "balanced", "deep"] as const;
|
package/src/execution-ui.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ExtensionCommandContext } from "@earendil-works/pi-coding-agent";
|
|
2
|
-
import type { AgentConfig, SubagentThinkingLevel } from "./agents.js";
|
|
2
|
+
import type { AgentConfig, SubagentThinkingLevel } from "./agents/types.js";
|
|
3
3
|
import {
|
|
4
4
|
applyExecutionProfile,
|
|
5
5
|
EXECUTION_PROFILES,
|