@gotgenes/pi-subagents 10.0.1 → 10.1.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 +25 -0
- package/docs/architecture/architecture.md +51 -140
- package/docs/architecture/history/phase-14-strip-policy.md +49 -0
- package/docs/plans/0227-evolve-agent-record-into-agent.md +322 -0
- package/docs/retro/0227-evolve-agent-record-into-agent.md +37 -0
- package/docs/retro/0239-collapse-filter-active-tools.md +33 -0
- package/package.json +1 -1
- package/src/lifecycle/agent-manager.ts +39 -89
- package/src/lifecycle/{agent-record.ts → agent.ts} +68 -10
- package/src/lifecycle/execution-state.ts +2 -2
- package/src/observation/notification.ts +8 -8
- package/src/observation/record-observer.ts +7 -7
- package/src/service/service-adapter.ts +8 -8
- package/src/tools/agent-tool.ts +4 -4
- package/src/tools/background-spawner.ts +2 -2
- package/src/tools/foreground-runner.ts +4 -4
- package/src/tools/get-result-tool.ts +2 -2
- package/src/tools/steer-tool.ts +4 -5
- package/src/types.ts +1 -1
- package/src/ui/agent-creation-wizard.ts +2 -2
- package/src/ui/agent-menu.ts +5 -5
- package/src/ui/conversation-viewer.ts +3 -3
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
textResult,
|
|
10
10
|
} from "#src/tools/helpers";
|
|
11
11
|
import type { ResolvedSpawnConfig } from "#src/tools/spawn-config";
|
|
12
|
-
import type {
|
|
12
|
+
import type { Agent } from "#src/types";
|
|
13
13
|
import { AgentActivityTracker } from "#src/ui/agent-activity-tracker";
|
|
14
14
|
import {
|
|
15
15
|
type AgentDetails,
|
|
@@ -26,7 +26,7 @@ export interface ForegroundManagerDeps {
|
|
|
26
26
|
type: string,
|
|
27
27
|
prompt: string,
|
|
28
28
|
opts: Omit<AgentSpawnConfig, "isBackground">,
|
|
29
|
-
): Promise<
|
|
29
|
+
): Promise<Agent>;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
/** Narrow widget interface for the foreground runner. */
|
|
@@ -62,7 +62,7 @@ export async function runForeground(
|
|
|
62
62
|
|
|
63
63
|
const fgState = new AgentActivityTracker(execution.effectiveMaxTurns);
|
|
64
64
|
let unsubUI: (() => void) | undefined;
|
|
65
|
-
let recordRef:
|
|
65
|
+
let recordRef: Agent | undefined;
|
|
66
66
|
|
|
67
67
|
const streamUpdate = () => {
|
|
68
68
|
const toolUses = recordRef?.toolUses ?? 0;
|
|
@@ -92,7 +92,7 @@ export async function runForeground(
|
|
|
92
92
|
|
|
93
93
|
streamUpdate();
|
|
94
94
|
|
|
95
|
-
let record:
|
|
95
|
+
let record: Agent;
|
|
96
96
|
try {
|
|
97
97
|
record = await manager.spawnAndWait(
|
|
98
98
|
params.snapshot,
|
|
@@ -4,13 +4,13 @@ import type { AgentConfigLookup } from "#src/config/agent-types";
|
|
|
4
4
|
import { getAgentConversation } from "#src/lifecycle/agent-runner";
|
|
5
5
|
import { getSessionContextPercent } from "#src/lifecycle/usage";
|
|
6
6
|
import { formatLifetimeTokens, textResult } from "#src/tools/helpers";
|
|
7
|
-
import type {
|
|
7
|
+
import type { Agent } from "#src/types";
|
|
8
8
|
import { formatDuration, getDisplayName } from "#src/ui/display";
|
|
9
9
|
|
|
10
10
|
// ---- Deps interfaces ----
|
|
11
11
|
|
|
12
12
|
export interface GetResultToolManager {
|
|
13
|
-
getRecord(id: string):
|
|
13
|
+
getRecord(id: string): Agent | undefined;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
export interface GetResultToolNotifications {
|
package/src/tools/steer-tool.ts
CHANGED
|
@@ -2,13 +2,12 @@ import { defineTool } from "@earendil-works/pi-coding-agent";
|
|
|
2
2
|
import { Type } from "@sinclair/typebox";
|
|
3
3
|
import { getSessionContextPercent } from "#src/lifecycle/usage";
|
|
4
4
|
import { formatLifetimeTokens, textResult } from "#src/tools/helpers";
|
|
5
|
-
import type {
|
|
5
|
+
import type { Agent } from "#src/types";
|
|
6
6
|
|
|
7
7
|
// ---- Deps interfaces ----
|
|
8
8
|
|
|
9
9
|
export interface SteerToolManager {
|
|
10
|
-
getRecord(id: string):
|
|
11
|
-
queueSteer(id: string, message: string): boolean;
|
|
10
|
+
getRecord(id: string): Agent | undefined;
|
|
12
11
|
}
|
|
13
12
|
|
|
14
13
|
export interface SteerToolEvents {
|
|
@@ -43,8 +42,8 @@ export class SteerTool {
|
|
|
43
42
|
}
|
|
44
43
|
const session = record.session;
|
|
45
44
|
if (!session) {
|
|
46
|
-
// Session not ready yet —
|
|
47
|
-
|
|
45
|
+
// Session not ready yet — buffer on the agent for delivery once initialized
|
|
46
|
+
record.queueSteer(params.message);
|
|
48
47
|
this.events.emit("subagents:steered", { id: record.id, message: params.message });
|
|
49
48
|
return textResult(
|
|
50
49
|
`Steering message queued for agent ${record.id}. It will be delivered once the session initializes.`,
|
package/src/types.ts
CHANGED
|
@@ -7,7 +7,7 @@ import type { AgentSessionEvent } from "@earendil-works/pi-coding-agent";
|
|
|
7
7
|
import type { ModelRegistry } from "#src/session/model-resolver";
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
export {
|
|
10
|
+
export { Agent } from "#src/lifecycle/agent";
|
|
11
11
|
export type { AgentSessionEvent, ThinkingLevel };
|
|
12
12
|
|
|
13
13
|
/**
|
|
@@ -9,7 +9,7 @@ import { join } from "node:path";
|
|
|
9
9
|
|
|
10
10
|
import { BUILTIN_TOOL_NAMES } from "#src/config/agent-types";
|
|
11
11
|
import type { ParentSnapshot } from "#src/lifecycle/parent-snapshot";
|
|
12
|
-
import type {
|
|
12
|
+
import type { Agent } from "#src/types";
|
|
13
13
|
import type { AgentFileOps } from "#src/ui/agent-file-ops";
|
|
14
14
|
import { writeAgentFile } from "#src/ui/agent-file-writer";
|
|
15
15
|
import type { MenuUI } from "#src/ui/agent-menu";
|
|
@@ -23,7 +23,7 @@ export interface WizardManager {
|
|
|
23
23
|
type: string,
|
|
24
24
|
prompt: string,
|
|
25
25
|
opts: { description: string; maxTurns: number },
|
|
26
|
-
) => Promise<
|
|
26
|
+
) => Promise<Agent>;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
/** Narrow registry interface for reloading after creation. */
|
package/src/ui/agent-menu.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { AgentTypeRegistry } from "#src/config/agent-types";
|
|
|
4
4
|
import type { ParentSnapshot } from "#src/lifecycle/parent-snapshot";
|
|
5
5
|
import { type ModelRegistry, resolveModel } from "#src/session/model-resolver";
|
|
6
6
|
import { getModelLabelFromConfig } from "#src/tools/helpers";
|
|
7
|
-
import type {
|
|
7
|
+
import type { Agent, AgentConfig } from "#src/types";
|
|
8
8
|
import type { AgentActivityTracker } from "#src/ui/agent-activity-tracker";
|
|
9
9
|
import { AgentConfigEditor } from "#src/ui/agent-config-editor";
|
|
10
10
|
import { AgentCreationWizard } from "#src/ui/agent-creation-wizard";
|
|
@@ -15,15 +15,15 @@ import { formatDuration, getDisplayName } from "#src/ui/display";
|
|
|
15
15
|
|
|
16
16
|
/** Narrow manager interface for menu operations. */
|
|
17
17
|
export interface AgentMenuManager {
|
|
18
|
-
listAgents: () =>
|
|
19
|
-
getRecord: (id: string) =>
|
|
18
|
+
listAgents: () => Agent[];
|
|
19
|
+
getRecord: (id: string) => Agent | undefined;
|
|
20
20
|
/** Used by generate wizard to spawn an agent that writes the .md file. */
|
|
21
21
|
spawnAndWait: (
|
|
22
22
|
parentSnapshot: ParentSnapshot,
|
|
23
23
|
type: string,
|
|
24
24
|
prompt: string,
|
|
25
25
|
opts: { description: string; maxTurns: number },
|
|
26
|
-
) => Promise<
|
|
26
|
+
) => Promise<Agent>;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
/** Narrow settings interface required by the agent menu. */
|
|
@@ -251,7 +251,7 @@ export class AgentsMenuHandler {
|
|
|
251
251
|
await this.showRunningAgents(ui);
|
|
252
252
|
}
|
|
253
253
|
|
|
254
|
-
private async viewAgentConversation(ui: MenuUI, record:
|
|
254
|
+
private async viewAgentConversation(ui: MenuUI, record: Agent): Promise<void> {
|
|
255
255
|
const session = record.session;
|
|
256
256
|
if (!session) {
|
|
257
257
|
ui.notify(
|
|
@@ -9,7 +9,7 @@ import type { AgentSession } from "@earendil-works/pi-coding-agent";
|
|
|
9
9
|
import { type Component, matchesKey, type TUI, truncateToWidth, visibleWidth } from "@earendil-works/pi-tui";
|
|
10
10
|
import type { AgentConfigLookup } from "#src/config/agent-types";
|
|
11
11
|
import { getLifetimeTotal, getSessionContextPercent } from "#src/lifecycle/usage";
|
|
12
|
-
import type {
|
|
12
|
+
import type { Agent } from "#src/types";
|
|
13
13
|
import type { AgentActivityTracker } from "#src/ui/agent-activity-tracker";
|
|
14
14
|
import { buildInvocationTags, formatDuration, formatSessionTokens, getDisplayName, getPromptModeLabel, type Theme } from "#src/ui/display";
|
|
15
15
|
import { formatMessage, formatStreamingIndicator } from "#src/ui/message-formatters";
|
|
@@ -25,7 +25,7 @@ export const VIEWPORT_HEIGHT_PCT = 70;
|
|
|
25
25
|
export interface ConversationViewerOptions {
|
|
26
26
|
tui: TUI;
|
|
27
27
|
session: AgentSession;
|
|
28
|
-
record:
|
|
28
|
+
record: Agent;
|
|
29
29
|
activity: AgentActivityTracker | undefined;
|
|
30
30
|
theme: Theme;
|
|
31
31
|
done: (result: undefined) => void;
|
|
@@ -42,7 +42,7 @@ export class ConversationViewer implements Component {
|
|
|
42
42
|
|
|
43
43
|
private tui: TUI;
|
|
44
44
|
private session: AgentSession;
|
|
45
|
-
private record:
|
|
45
|
+
private record: Agent;
|
|
46
46
|
private activity: AgentActivityTracker | undefined;
|
|
47
47
|
private theme: Theme;
|
|
48
48
|
private done: (result: undefined) => void;
|