@narumitw/pi-subagents 0.53.0 → 1.0.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 +85 -15
- 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 +82 -11
- 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 +39 -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 +106 -7
- package/src/registry-types.ts +22 -5
- package/src/registry.ts +205 -37
- 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 +2 -2
- package/src/stateful-limits.ts +1 -1
- package/src/stateful-prompt.ts +2 -2
- package/src/stateful-render.ts +0 -1
- package/src/stateful-safety.ts +2 -1
- package/src/stateful-tool-params.ts +13 -20
- package/src/stateful.ts +36 -117
- 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/stateful-render.ts
CHANGED
|
@@ -75,7 +75,6 @@ function renderStatefulCall(tool: StatefulRenderTool, args: Record<string, unkno
|
|
|
75
75
|
const metadata: string[] = [];
|
|
76
76
|
if (typeof args.agentId === "string") metadata.push(`id:${safeLine(args.agentId, "", 256)}`);
|
|
77
77
|
if (args.subtree === true) metadata.push("subtree");
|
|
78
|
-
if (args.includeClosed === true) metadata.push("include closed");
|
|
79
78
|
return new Text(toolHeader(theme, "subagent_manage", args.action, metadata), 0, 0);
|
|
80
79
|
}
|
|
81
80
|
const metadata = [`id:${safeLine(args.agentId, "...", 256)}`];
|
package/src/stateful-safety.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { realpathSync } from "node:fs";
|
|
2
2
|
import * as path from "node:path";
|
|
3
3
|
import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
4
|
-
import {
|
|
4
|
+
import { discoverAgents } from "./agents/discovery.js";
|
|
5
|
+
import type { AgentScope, SubagentSettings } from "./agents/types.js";
|
|
5
6
|
import type { AgentRegistry, ManagedAgent } from "./registry.js";
|
|
6
7
|
import { safeTerminalLine } from "./safe-text.js";
|
|
7
8
|
import { readSubagentSettings } from "./settings.js";
|
|
@@ -1,25 +1,18 @@
|
|
|
1
1
|
import { StringEnum } from "@earendil-works/pi-ai";
|
|
2
2
|
import { Type } from "typebox";
|
|
3
3
|
|
|
4
|
-
const MANAGE_ACTIONS = ["
|
|
4
|
+
const MANAGE_ACTIONS = ["interrupt", "close"] as const;
|
|
5
5
|
const MAILBOX_ACTIONS = ["send", "read"] as const;
|
|
6
6
|
const MAX_MAILBOX_MESSAGE_LENGTH = 16 * 1024;
|
|
7
7
|
|
|
8
8
|
export const ManageParamsSchema = Type.Object(
|
|
9
9
|
{
|
|
10
10
|
action: StringEnum(MANAGE_ACTIONS, {
|
|
11
|
-
description:
|
|
12
|
-
"Use list to inspect agents, interrupt to stop active work, or close to release agents.",
|
|
11
|
+
description: "Interrupt active work or close an agent and release its resources.",
|
|
13
12
|
}),
|
|
14
13
|
agentId: Type.Optional(
|
|
15
14
|
Type.String({ minLength: 1, description: "Required for interrupt and close." }),
|
|
16
15
|
),
|
|
17
|
-
includeClosed: Type.Optional(
|
|
18
|
-
Type.Boolean({
|
|
19
|
-
default: false,
|
|
20
|
-
description: "List closed records as well as retained agents.",
|
|
21
|
-
}),
|
|
22
|
-
),
|
|
23
16
|
subtree: Type.Optional(
|
|
24
17
|
Type.Boolean({
|
|
25
18
|
default: false,
|
|
@@ -57,9 +50,11 @@ export const MailboxParamsSchema = Type.Object(
|
|
|
57
50
|
{ additionalProperties: false },
|
|
58
51
|
);
|
|
59
52
|
|
|
60
|
-
export type ValidatedManageParams =
|
|
61
|
-
|
|
62
|
-
|
|
53
|
+
export type ValidatedManageParams = {
|
|
54
|
+
action: "interrupt" | "close";
|
|
55
|
+
agentId: string;
|
|
56
|
+
subtree?: boolean;
|
|
57
|
+
};
|
|
63
58
|
|
|
64
59
|
export type ValidatedMailboxParams =
|
|
65
60
|
| {
|
|
@@ -73,21 +68,19 @@ export type ValidatedMailboxParams =
|
|
|
73
68
|
|
|
74
69
|
export function validateManageParams(params: unknown): ValidatedManageParams {
|
|
75
70
|
const values = parameterRecord(params, "subagent_manage");
|
|
76
|
-
assertKnownKeys("subagent_manage", values, ["action", "agentId", "
|
|
71
|
+
assertKnownKeys("subagent_manage", values, ["action", "agentId", "subtree"]);
|
|
77
72
|
const action = values.action;
|
|
73
|
+
if (action === "list") {
|
|
74
|
+
throw new Error(
|
|
75
|
+
'subagent_manage no longer supports "list"; use subagent_inspect action "list_runs"',
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
78
|
if (
|
|
79
79
|
typeof action !== "string" ||
|
|
80
80
|
!MANAGE_ACTIONS.includes(action as (typeof MANAGE_ACTIONS)[number])
|
|
81
81
|
) {
|
|
82
82
|
throw new Error(`subagent_manage action must be one of: ${MANAGE_ACTIONS.join(", ")}`);
|
|
83
83
|
}
|
|
84
|
-
if (action === "list") {
|
|
85
|
-
assertOptionalBoolean("subagent_manage", action, values, "includeClosed");
|
|
86
|
-
return {
|
|
87
|
-
action,
|
|
88
|
-
...(values.includeClosed === undefined ? {} : { includeClosed: values.includeClosed }),
|
|
89
|
-
} as ValidatedManageParams;
|
|
90
|
-
}
|
|
91
84
|
assertRequiredString("subagent_manage", action, values, "agentId");
|
|
92
85
|
assertOptionalBoolean("subagent_manage", action, values, "subtree");
|
|
93
86
|
return {
|
package/src/stateful.ts
CHANGED
|
@@ -2,20 +2,21 @@
|
|
|
2
2
|
* Stateful registration remains one lifecycle owner so session replacement, persistence,
|
|
3
3
|
* capability revocation, workspace cleanup, and completion delivery cannot reorder.
|
|
4
4
|
*/
|
|
5
|
+
|
|
5
6
|
import { randomUUID } from "node:crypto";
|
|
6
7
|
import { StringEnum } from "@earendil-works/pi-ai";
|
|
7
8
|
import { defineTool, type ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
8
9
|
import { Type } from "typebox";
|
|
10
|
+
import { discoverAgents } from "./agents/discovery.js";
|
|
9
11
|
import {
|
|
10
12
|
type AgentScope,
|
|
11
13
|
type CompletionDelivery,
|
|
12
|
-
discoverAgents,
|
|
13
14
|
isThinkingLevel,
|
|
14
15
|
type SubagentRuntimeSettings,
|
|
15
16
|
type SubagentSettings,
|
|
16
17
|
type SubagentTransportKind,
|
|
17
18
|
THINKING_LEVELS,
|
|
18
|
-
} from "./agents.js";
|
|
19
|
+
} from "./agents/types.js";
|
|
19
20
|
import { issueCapabilityGrant } from "./capability-grant.js";
|
|
20
21
|
import { CompletionDeliveryBroker } from "./completion-delivery.js";
|
|
21
22
|
import { buildContextSnapshot, type ContextMode, redactPrivateText } from "./context.js";
|
|
@@ -26,9 +27,14 @@ import {
|
|
|
26
27
|
targetPolicyAudit,
|
|
27
28
|
} from "./cwd-policy.js";
|
|
28
29
|
import { DelegationContractSchema, normalizeDelegationContract } from "./delegation-contract.js";
|
|
29
|
-
import { assertSubagentDepthAllowed } from "./execution.js";
|
|
30
|
+
import { assertSubagentDepthAllowed } from "./execution/runtime-policy.js";
|
|
30
31
|
import type { ChildSessionFactory, ParentRuntimeSnapshot } from "./in-process-transport.js";
|
|
31
|
-
import {
|
|
32
|
+
import {
|
|
33
|
+
DEFAULT_MAX_CONTEXT_BYTES,
|
|
34
|
+
MAX_SUBAGENT_TIMEOUT_MS,
|
|
35
|
+
MAX_TOOL_MESSAGE_BYTES,
|
|
36
|
+
truncateUtf8,
|
|
37
|
+
} from "./limits.js";
|
|
32
38
|
import { AgentPersistence } from "./persistence.js";
|
|
33
39
|
import {
|
|
34
40
|
AgentRegistry,
|
|
@@ -39,12 +45,14 @@ import {
|
|
|
39
45
|
import { SUBAGENT_RESULT_FORMATS, type SubagentResultFormat } from "./result-contract.js";
|
|
40
46
|
import { buildRetainedSemanticState } from "./retained-semantic-state.js";
|
|
41
47
|
import { evaluateSemanticCompatibility } from "./semantic-snapshot.js";
|
|
42
|
-
import { DEFAULT_DELEGATION_CWD_POLICY
|
|
48
|
+
import { DEFAULT_DELEGATION_CWD_POLICY } from "./settings/inspection.js";
|
|
49
|
+
import { readSubagentSettings } from "./settings.js";
|
|
43
50
|
import {
|
|
44
51
|
assertSpawnIdempotencyKey,
|
|
45
52
|
hashSpawnRequest,
|
|
46
53
|
MAX_SPAWN_IDEMPOTENCY_KEY_LENGTH,
|
|
47
54
|
} from "./spawn-idempotency.js";
|
|
55
|
+
import { summarizeStatefulAgent } from "./stateful-agent-view.js";
|
|
48
56
|
import { resolveCompletionDelivery, resolveStatefulTransportKind } from "./stateful-config.js";
|
|
49
57
|
import { createSpawnPromptGuidelines } from "./stateful-guidance.js";
|
|
50
58
|
import {
|
|
@@ -119,8 +127,6 @@ const StatefulTurnLimitFields = {
|
|
|
119
127
|
}),
|
|
120
128
|
),
|
|
121
129
|
};
|
|
122
|
-
const MAX_TOOL_MESSAGE_BYTES = 2 * 1024;
|
|
123
|
-
|
|
124
130
|
export interface StatefulSubagentDependencies {
|
|
125
131
|
blockingEnabled?: boolean;
|
|
126
132
|
createInProcessSession?: ChildSessionFactory;
|
|
@@ -294,10 +300,16 @@ export function registerStatefulSubagents(
|
|
|
294
300
|
const reason = error instanceof Error ? error.message : String(error);
|
|
295
301
|
ctx.ui.notify(`Subagent completion delivery failed: ${reason}`, "warning");
|
|
296
302
|
},
|
|
297
|
-
|
|
303
|
+
onAcknowledged: (completions, deliveredAt) => {
|
|
298
304
|
if (generation !== runtimeGeneration) return;
|
|
299
305
|
for (const completion of completions) {
|
|
300
|
-
nextRegistry
|
|
306
|
+
void nextRegistry
|
|
307
|
+
.markCompletionDelivered(completion.completionId, deliveredAt)
|
|
308
|
+
.catch((error: unknown) => {
|
|
309
|
+
if (!ctx.hasUI || generation !== runtimeGeneration) return;
|
|
310
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
311
|
+
ctx.ui.notify(`Subagent completion acknowledgement failed: ${reason}`, "warning");
|
|
312
|
+
});
|
|
301
313
|
}
|
|
302
314
|
},
|
|
303
315
|
});
|
|
@@ -372,6 +384,9 @@ export function registerStatefulSubagents(
|
|
|
372
384
|
registry = nextRegistry;
|
|
373
385
|
persistence = sessionPersistence;
|
|
374
386
|
completionBroker = sessionBroker;
|
|
387
|
+
for (const completion of nextRegistry.listPendingCompletions()) {
|
|
388
|
+
sessionBroker.enqueue(completion);
|
|
389
|
+
}
|
|
375
390
|
runtimeLimits = nextLimits;
|
|
376
391
|
refreshSpawnToolRegistration?.();
|
|
377
392
|
const sweepEveryMs = Math.max(
|
|
@@ -396,6 +411,10 @@ export function registerStatefulSubagents(
|
|
|
396
411
|
completionBroker?.onParentTurnStart();
|
|
397
412
|
});
|
|
398
413
|
|
|
414
|
+
pi.on("context", (event) => {
|
|
415
|
+
completionBroker?.onParentContext(event.messages);
|
|
416
|
+
});
|
|
417
|
+
|
|
399
418
|
pi.on("agent_settled", () => {
|
|
400
419
|
completionBroker?.onParentSettled();
|
|
401
420
|
});
|
|
@@ -829,8 +848,8 @@ export function registerStatefulSubagents(
|
|
|
829
848
|
name: "subagent_manage",
|
|
830
849
|
label: "Manage Subagents",
|
|
831
850
|
description:
|
|
832
|
-
"
|
|
833
|
-
promptSnippet: "
|
|
851
|
+
"Interrupt active work while keeping an agent reusable, or close agents and release their resources. Use subagent_inspect for every read-only list, detail, status, and diagnostic operation.",
|
|
852
|
+
promptSnippet: "Interrupt or close retained detached subagents",
|
|
834
853
|
parameters: ManageParamsSchema,
|
|
835
854
|
...createStatefulToolRenderer("manage"),
|
|
836
855
|
async execute(_id, params, signal): Promise<StatefulActionToolResult> {
|
|
@@ -842,18 +861,6 @@ export function registerStatefulSubagents(
|
|
|
842
861
|
return value;
|
|
843
862
|
};
|
|
844
863
|
const operation = validateManageParams(params);
|
|
845
|
-
if (operation.action === "list") {
|
|
846
|
-
const agents = ownedRegistry.list(operation.includeClosed);
|
|
847
|
-
return {
|
|
848
|
-
content: [
|
|
849
|
-
{
|
|
850
|
-
type: "text",
|
|
851
|
-
text: agents.length ? agents.map(formatLine).join("\n") : "No stateful subagents.",
|
|
852
|
-
},
|
|
853
|
-
],
|
|
854
|
-
details: { agents: agents.map(summarizeAgent) },
|
|
855
|
-
};
|
|
856
|
-
}
|
|
857
864
|
const agentId = operation.agentId;
|
|
858
865
|
if (operation.action === "interrupt") {
|
|
859
866
|
if (operation.subtree) {
|
|
@@ -862,8 +869,8 @@ export function registerStatefulSubagents(
|
|
|
862
869
|
return {
|
|
863
870
|
content: [{ type: "text", text: `Interrupted ${agents.length} active agent(s).` }],
|
|
864
871
|
details: {
|
|
865
|
-
agent:
|
|
866
|
-
agents: agents.map(
|
|
872
|
+
agent: summarizeStatefulAgent(ownedAgent(agentId)),
|
|
873
|
+
agents: agents.map(summarizeStatefulAgent),
|
|
867
874
|
},
|
|
868
875
|
};
|
|
869
876
|
}
|
|
@@ -890,8 +897,8 @@ export function registerStatefulSubagents(
|
|
|
890
897
|
return {
|
|
891
898
|
content: [{ type: "text", text: `Closed ${agents.length} agent(s).` }],
|
|
892
899
|
details: {
|
|
893
|
-
agent:
|
|
894
|
-
agents: agents.map(
|
|
900
|
+
agent: summarizeStatefulAgent(ownedAgent(agentId)),
|
|
901
|
+
agents: agents.map(summarizeStatefulAgent),
|
|
895
902
|
},
|
|
896
903
|
};
|
|
897
904
|
}
|
|
@@ -970,95 +977,6 @@ export function resolveSpawnContextMode(
|
|
|
970
977
|
return normalizeContextMode(value);
|
|
971
978
|
}
|
|
972
979
|
|
|
973
|
-
export function formatStatefulAgentLine(agent: ManagedAgent): string {
|
|
974
|
-
const elapsedSeconds = Math.max(0, Math.floor((Date.now() - agent.updatedAt) / 1000));
|
|
975
|
-
const actions =
|
|
976
|
-
agent.state === "running" || agent.state === "starting"
|
|
977
|
-
? "interrupt, close"
|
|
978
|
-
: agent.state === "closed"
|
|
979
|
-
? "inspect"
|
|
980
|
-
: "send, close";
|
|
981
|
-
const task = agent.currentTask ? ` — ${sanitizeStatusLine(agent.currentTask, 80)}` : "";
|
|
982
|
-
const unread = agent.mailbox.filter((message) => !message.readAt).length;
|
|
983
|
-
const indent = " ".repeat(agent.depth);
|
|
984
|
-
const thinking = agent.thinkingLevel ? ` thinking:${agent.thinkingLevel}` : "";
|
|
985
|
-
const timeout = agent.currentTimeoutMs ?? agent.timeoutMs;
|
|
986
|
-
const timeoutText = timeout ? ` timeout:${timeout}ms` : "";
|
|
987
|
-
const idleTimeout = agent.currentIdleTimeoutMs ?? agent.idleTimeoutMs;
|
|
988
|
-
const idleText = idleTimeout ? ` idle:${idleTimeout}ms` : "";
|
|
989
|
-
const maxTurns = agent.currentMaxTurns ?? agent.maxTurns;
|
|
990
|
-
const turnsText = maxTurns ? ` turns:${maxTurns}` : "";
|
|
991
|
-
const maxToolCalls = agent.currentMaxToolCalls ?? agent.maxToolCalls;
|
|
992
|
-
const toolsText = maxToolCalls ? ` tools:${maxToolCalls}` : "";
|
|
993
|
-
const transport = agent.telemetry?.transport ? ` transport:${agent.telemetry.transport}` : "";
|
|
994
|
-
const phase = agent.telemetry?.phase ? ` phase:${agent.telemetry.phase}` : "";
|
|
995
|
-
const queued = agent.telemetry?.queuePosition ? ` queue:${agent.telemetry.queuePosition}` : "";
|
|
996
|
-
return `${indent}${sanitizeStatusLine(agent.id, 128)} ${sanitizeStatusLine(agent.agent, 128)} ${agent.state} ${elapsedSeconds}s${thinking}${timeoutText}${idleText}${turnsText}${toolsText}${transport}${phase}${queued} unread:${unread} [${actions}]${task}`;
|
|
997
|
-
}
|
|
998
|
-
|
|
999
|
-
function sanitizeStatusLine(value: string, maxLength: number): string {
|
|
1000
|
-
return (
|
|
1001
|
-
value
|
|
1002
|
-
.slice(0, maxLength)
|
|
1003
|
-
// biome-ignore lint/suspicious/noControlCharactersInRegex: Escape untrusted terminal controls.
|
|
1004
|
-
.replace(/[\u0000-\u001f\u007f-\u009f]/gu, " ")
|
|
1005
|
-
.replace(/\s+/gu, " ")
|
|
1006
|
-
.trim()
|
|
1007
|
-
);
|
|
1008
|
-
}
|
|
1009
|
-
|
|
1010
|
-
function formatLine(agent: ManagedAgent): string {
|
|
1011
|
-
return formatStatefulAgentLine(agent);
|
|
1012
|
-
}
|
|
1013
|
-
|
|
1014
|
-
function summarizeAgent(agent: ManagedAgent) {
|
|
1015
|
-
return {
|
|
1016
|
-
id: agent.id,
|
|
1017
|
-
agent: agent.agent,
|
|
1018
|
-
parentId: agent.parentId,
|
|
1019
|
-
rootId: agent.rootId,
|
|
1020
|
-
depth: agent.depth,
|
|
1021
|
-
children: [...agent.children],
|
|
1022
|
-
state: agent.state,
|
|
1023
|
-
createdAt: agent.createdAt,
|
|
1024
|
-
updatedAt: agent.updatedAt,
|
|
1025
|
-
cwd: agent.cwd,
|
|
1026
|
-
workspaceMode: agent.workspaceMode ?? "shared",
|
|
1027
|
-
thinkingLevel: agent.thinkingLevel,
|
|
1028
|
-
timeoutMs: agent.timeoutMs,
|
|
1029
|
-
currentTimeoutMs: agent.currentTimeoutMs,
|
|
1030
|
-
idleTimeoutMs: agent.idleTimeoutMs,
|
|
1031
|
-
currentIdleTimeoutMs: agent.currentIdleTimeoutMs,
|
|
1032
|
-
maxTurns: agent.maxTurns,
|
|
1033
|
-
currentMaxTurns: agent.currentMaxTurns,
|
|
1034
|
-
maxToolCalls: agent.maxToolCalls,
|
|
1035
|
-
currentMaxToolCalls: agent.currentMaxToolCalls,
|
|
1036
|
-
currentTask: agent.currentTask
|
|
1037
|
-
? truncateUtf8(agent.currentTask, MAX_TOOL_MESSAGE_BYTES).text
|
|
1038
|
-
: undefined,
|
|
1039
|
-
historyCount: agent.history.length,
|
|
1040
|
-
unreadMessages: agent.mailbox.filter((message) => !message.readAt).length,
|
|
1041
|
-
context: {
|
|
1042
|
-
turns: agent.contextTurns ?? 0,
|
|
1043
|
-
sources: agent.contextSourceIds?.length ?? 0,
|
|
1044
|
-
bytes: agent.contextBytes ?? 0,
|
|
1045
|
-
truncated: agent.contextTruncated === true,
|
|
1046
|
-
},
|
|
1047
|
-
resultFormat: agent.resultFormat ?? "text",
|
|
1048
|
-
structuredResult: agent.structuredResult,
|
|
1049
|
-
termination: agent.termination,
|
|
1050
|
-
outcome: agent.outcome,
|
|
1051
|
-
executionPlan: agent.executionPlan,
|
|
1052
|
-
capabilityGrant: agent.capabilityGrant,
|
|
1053
|
-
semanticCompatibility: agent.semanticCompatibility,
|
|
1054
|
-
semanticSnapshotDigest: agent.semanticSnapshot?.digest,
|
|
1055
|
-
telemetry: agent.telemetry,
|
|
1056
|
-
error: agent.error ? truncateUtf8(agent.error, MAX_TOOL_MESSAGE_BYTES).text : undefined,
|
|
1057
|
-
target: agent.target,
|
|
1058
|
-
policy: agent.policy,
|
|
1059
|
-
};
|
|
1060
|
-
}
|
|
1061
|
-
|
|
1062
980
|
async function cleanupClosedWorkspaces(
|
|
1063
981
|
registry: AgentRegistry,
|
|
1064
982
|
isolatedAgents: Map<string, string>,
|
|
@@ -1078,7 +996,7 @@ function appendAgentCatalog(baseDescription: string, catalog: string): string {
|
|
|
1078
996
|
function result(agent: ManagedAgent, text: string) {
|
|
1079
997
|
return {
|
|
1080
998
|
content: [{ type: "text" as const, text }],
|
|
1081
|
-
details: { agent:
|
|
999
|
+
details: { agent: summarizeStatefulAgent(agent) },
|
|
1082
1000
|
};
|
|
1083
1001
|
}
|
|
1084
1002
|
|
|
@@ -1090,6 +1008,7 @@ export {
|
|
|
1090
1008
|
buildDetachedCompletionMessage,
|
|
1091
1009
|
CompletionDeliveryBroker,
|
|
1092
1010
|
} from "./completion-delivery.js";
|
|
1011
|
+
export { formatStatefulAgentLine } from "./stateful-agent-view.js";
|
|
1093
1012
|
export { resolveCompletionDelivery, resolveStatefulTransportKind } from "./stateful-config.js";
|
|
1094
1013
|
export {
|
|
1095
1014
|
buildStatefulTurnPrompt,
|
package/src/subagents.ts
CHANGED
|
@@ -14,14 +14,13 @@ import {
|
|
|
14
14
|
type ExtensionAPI,
|
|
15
15
|
type ToolDefinition,
|
|
16
16
|
} from "@earendil-works/pi-coding-agent";
|
|
17
|
-
import {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
} from "./agents.js";
|
|
17
|
+
import { discoverAgentCatalog, formatAgentCatalog } from "./agents/catalog.js";
|
|
18
|
+
import type {
|
|
19
|
+
ConsultationCwdPolicy,
|
|
20
|
+
ConsultResourcePolicy,
|
|
21
|
+
DelegationCwdPolicy,
|
|
22
|
+
SubagentSettings,
|
|
23
|
+
} from "./agents/types.js";
|
|
25
24
|
import { registerSubagentAutomation } from "./automation.js";
|
|
26
25
|
import { registerSubagentConfigCommand, registerSubagentConfigLifecycle } from "./config-ui.js";
|
|
27
26
|
import { registerSubagentConsult } from "./consult.js";
|
|
@@ -256,7 +255,7 @@ function appendAgentCatalog(baseDescription: string, catalog: string): string {
|
|
|
256
255
|
return catalog ? `${baseDescription}\n\n${catalog}` : baseDescription;
|
|
257
256
|
}
|
|
258
257
|
|
|
259
|
-
export { parsePositiveInteger } from "./execution.js";
|
|
258
|
+
export { parsePositiveInteger } from "./execution/runtime-policy.js";
|
|
260
259
|
export { formatTokens, formatUsageStats } from "./render.js";
|
|
261
260
|
export { buildPiArgs } from "./runner.js";
|
|
262
261
|
export {
|
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
discoverAgents,
|
|
4
|
-
type SubagentSettings,
|
|
5
|
-
type SubagentThinkingLevel,
|
|
6
|
-
} from "./agents.js";
|
|
1
|
+
import { discoverAgents } from "./agents/discovery.js";
|
|
2
|
+
import type { AgentConfig, SubagentSettings, SubagentThinkingLevel } from "./agents/types.js";
|
|
7
3
|
import { resolvePiPromptResources } from "./prompt-resources.js";
|
|
8
4
|
import type { ManagedAgent, TurnOutcome } from "./registry.js";
|
|
9
5
|
import { getResultFinalOutput, runSingleAgent, type SubagentDetails } from "./runner.js";
|
package/src/transport-types.ts
CHANGED
package/src/transport-ui.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ExtensionCommandContext } from "@earendil-works/pi-coding-agent";
|
|
2
|
-
import type { SubagentTransportKind } from "./agents.js";
|
|
2
|
+
import type { SubagentTransportKind } from "./agents/types.js";
|
|
3
3
|
import { safeTerminalLine as safeTerminalText } from "./safe-text.js";
|
|
4
4
|
import { inspectStatefulTransportSettings, updateStatefulTransportSetting } from "./settings.js";
|
|
5
5
|
import type { StatefulSubagentRuntimeStatus } from "./stateful.js";
|