@gotgenes/pi-subagents 6.17.0 → 6.17.2
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 +27 -0
- package/docs/architecture/architecture.md +588 -536
- package/docs/architecture/history/phase-1-api-boundary.md +8 -0
- package/docs/architecture/history/phase-2-remove-scheduling.md +9 -0
- package/docs/architecture/history/phase-3-remove-rpc-groupjoin.md +11 -0
- package/docs/architecture/history/phase-4-implement-service.md +8 -0
- package/docs/architecture/history/phase-5-decompose-index.md +42 -0
- package/docs/architecture/history/phase-7-encapsulation.md +173 -0
- package/docs/architecture/history/phase-8-testability.md +103 -0
- package/docs/architecture/history/phase-9-observation-ctx.md +122 -0
- package/docs/plans/0164-reorganize-into-domain-directories.md +409 -0
- package/docs/retro/0147-inject-wrap-text-into-conversation-viewer.md +40 -0
- package/docs/retro/0164-reorganize-into-domain-directories.md +46 -0
- package/package.json +5 -1
- package/src/{agent-types.ts → config/agent-types.ts} +2 -2
- package/src/{custom-agents.ts → config/custom-agents.ts} +3 -3
- package/src/{default-agents.ts → config/default-agents.ts} +1 -1
- package/src/{invocation-config.ts → config/invocation-config.ts} +1 -1
- package/src/handlers/index.ts +2 -2
- package/src/index.ts +26 -26
- package/src/{agent-manager.ts → lifecycle/agent-manager.ts} +11 -11
- package/src/{agent-record.ts → lifecycle/agent-record.ts} +6 -6
- package/src/{agent-runner.ts → lifecycle/agent-runner.ts} +6 -6
- package/src/{parent-snapshot.ts → lifecycle/parent-snapshot.ts} +1 -1
- package/src/{worktree-state.ts → lifecycle/worktree-state.ts} +1 -1
- package/src/{worktree.ts → lifecycle/worktree.ts} +1 -1
- package/src/{notification.ts → observation/notification.ts} +4 -4
- package/src/{record-observer.ts → observation/record-observer.ts} +2 -2
- package/src/{renderer.ts → observation/renderer.ts} +2 -2
- package/src/runtime.ts +2 -2
- package/src/{service-adapter.ts → service/service-adapter.ts} +5 -5
- package/src/{service.ts → service/service.ts} +1 -1
- package/src/{env.ts → session/env.ts} +2 -2
- package/src/{memory.ts → session/memory.ts} +2 -2
- package/src/{prompts.ts → session/prompts.ts} +2 -2
- package/src/{session-config.ts → session/session-config.ts} +5 -5
- package/src/{skill-loader.ts → session/skill-loader.ts} +2 -2
- package/src/tools/agent-tool.ts +11 -12
- package/src/tools/background-spawner.ts +8 -8
- package/src/tools/foreground-runner.ts +14 -14
- package/src/tools/get-result-tool.ts +5 -5
- package/src/tools/helpers.ts +4 -4
- package/src/tools/spawn-config.ts +6 -6
- package/src/tools/steer-tool.ts +3 -3
- package/src/types.ts +1 -1
- package/src/ui/agent-activity-tracker.ts +1 -1
- package/src/ui/agent-config-editor.ts +4 -4
- package/src/ui/agent-creation-wizard.ts +5 -5
- package/src/ui/agent-menu.ts +10 -10
- package/src/ui/agent-widget.ts +5 -5
- package/src/ui/conversation-viewer.ts +6 -6
- package/src/ui/display.ts +2 -2
- package/src/ui/ui-observer.ts +1 -1
- package/src/ui/widget-renderer.ts +5 -5
- package/vitest.config.ts +14 -0
- /package/src/{execution-state.ts → lifecycle/execution-state.ts} +0 -0
- /package/src/{usage.ts → lifecycle/usage.ts} +0 -0
- /package/src/{notification-state.ts → observation/notification-state.ts} +0 -0
- /package/src/{context.ts → session/context.ts} +0 -0
- /package/src/{model-resolver.ts → session/model-resolver.ts} +0 -0
- /package/src/{session-dir.ts → session/session-dir.ts} +0 -0
package/src/index.ts
CHANGED
|
@@ -20,35 +20,35 @@ import {
|
|
|
20
20
|
SettingsManager as SdkSettingsManager,
|
|
21
21
|
SessionManager,
|
|
22
22
|
} from "@earendil-works/pi-coding-agent";
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
30
|
-
import { type
|
|
31
|
-
import {
|
|
32
|
-
import {
|
|
33
|
-
import {
|
|
34
|
-
import {
|
|
35
|
-
import {
|
|
36
|
-
import {
|
|
37
|
-
import {
|
|
38
|
-
import {
|
|
39
|
-
import {
|
|
40
|
-
import { preloadSkills } from "
|
|
41
|
-
import {
|
|
42
|
-
import {
|
|
43
|
-
import {
|
|
44
|
-
import {
|
|
45
|
-
import {
|
|
46
|
-
import {
|
|
23
|
+
import { AgentTypeRegistry } from "#src/config/agent-types";
|
|
24
|
+
import { loadCustomAgents } from "#src/config/custom-agents";
|
|
25
|
+
import { SessionLifecycleHandler, ToolStartHandler } from "#src/handlers/index";
|
|
26
|
+
import { AgentManager, type AgentManagerObserver } from "#src/lifecycle/agent-manager";
|
|
27
|
+
import { createAgentRunner, getAgentConversation, type RunnerIO, steerAgent } from "#src/lifecycle/agent-runner";
|
|
28
|
+
import { buildParentSnapshot } from "#src/lifecycle/parent-snapshot";
|
|
29
|
+
import { GitWorktreeManager } from "#src/lifecycle/worktree";
|
|
30
|
+
import { buildEventData, type NotificationDetails, NotificationManager } from "#src/observation/notification";
|
|
31
|
+
import { createNotificationRenderer } from "#src/observation/renderer";
|
|
32
|
+
import { createSubagentRuntime } from "#src/runtime";
|
|
33
|
+
import { publishSubagentsService, unpublishSubagentsService } from "#src/service/service";
|
|
34
|
+
import { createSubagentsService } from "#src/service/service-adapter";
|
|
35
|
+
import { detectEnv } from "#src/session/env";
|
|
36
|
+
import { buildMemoryBlock, buildReadOnlyMemoryBlock } from "#src/session/memory";
|
|
37
|
+
import { type ModelRegistry, resolveModel } from "#src/session/model-resolver";
|
|
38
|
+
import { buildAgentPrompt } from "#src/session/prompts";
|
|
39
|
+
import { deriveSubagentSessionDir } from "#src/session/session-dir";
|
|
40
|
+
import { preloadSkills } from "#src/session/skill-loader";
|
|
41
|
+
import { SettingsManager } from "#src/settings";
|
|
42
|
+
import { createAgentTool } from "#src/tools/agent-tool";
|
|
43
|
+
import { createGetResultTool } from "#src/tools/get-result-tool";
|
|
44
|
+
import { getModelLabelFromConfig } from "#src/tools/helpers";
|
|
45
|
+
import { createSteerTool } from "#src/tools/steer-tool";
|
|
46
|
+
import { FsAgentFileOps } from "#src/ui/agent-file-ops";
|
|
47
|
+
import { createAgentsMenuHandler } from "#src/ui/agent-menu";
|
|
47
48
|
import {
|
|
48
49
|
AgentWidget,
|
|
49
50
|
type UICtx,
|
|
50
|
-
} from "
|
|
51
|
-
import { GitWorktreeManager } from "./worktree.js";
|
|
51
|
+
} from "#src/ui/agent-widget";
|
|
52
52
|
|
|
53
53
|
export default function (pi: ExtensionAPI) {
|
|
54
54
|
// ---- Register custom notification renderer ----
|
|
@@ -9,17 +9,17 @@
|
|
|
9
9
|
import { randomUUID } from "node:crypto";
|
|
10
10
|
import type { Model } from "@earendil-works/pi-ai";
|
|
11
11
|
import type { AgentSession } from "@earendil-works/pi-coding-agent";
|
|
12
|
-
import {
|
|
13
|
-
import
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import type {
|
|
18
|
-
import {
|
|
19
|
-
import
|
|
20
|
-
import
|
|
21
|
-
import type {
|
|
22
|
-
import {
|
|
12
|
+
import { AgentTypeRegistry } from "#src/config/agent-types";
|
|
13
|
+
import { debugLog } from "#src/debug";
|
|
14
|
+
import { AgentRecord } from "#src/lifecycle/agent-record";
|
|
15
|
+
import type { AgentRunner } from "#src/lifecycle/agent-runner";
|
|
16
|
+
import type { ParentSnapshot } from "#src/lifecycle/parent-snapshot";
|
|
17
|
+
import type { WorktreeManager } from "#src/lifecycle/worktree";
|
|
18
|
+
import { WorktreeState } from "#src/lifecycle/worktree-state";
|
|
19
|
+
import { NotificationState } from "#src/observation/notification-state";
|
|
20
|
+
import { subscribeRecordObserver } from "#src/observation/record-observer";
|
|
21
|
+
import type { RunConfig } from "#src/runtime";
|
|
22
|
+
import type { AgentInvocation, IsolationMode, ShellExec, SubagentType, ThinkingLevel } from "#src/types";
|
|
23
23
|
|
|
24
24
|
export type CompactionInfo = { reason: "manual" | "threshold" | "overflow"; tokensBefore: number };
|
|
25
25
|
|
|
@@ -13,12 +13,12 @@
|
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
15
|
import type { AgentSession } from "@earendil-works/pi-coding-agent";
|
|
16
|
-
import type { ExecutionState } from "
|
|
17
|
-
import type {
|
|
18
|
-
import
|
|
19
|
-
import type {
|
|
20
|
-
import {
|
|
21
|
-
import type {
|
|
16
|
+
import type { ExecutionState } from "#src/lifecycle/execution-state";
|
|
17
|
+
import type { LifetimeUsage } from "#src/lifecycle/usage";
|
|
18
|
+
import { addUsage } from "#src/lifecycle/usage";
|
|
19
|
+
import type { WorktreeState } from "#src/lifecycle/worktree-state";
|
|
20
|
+
import type { NotificationState } from "#src/observation/notification-state";
|
|
21
|
+
import type { AgentInvocation, SubagentType } from "#src/types";
|
|
22
22
|
|
|
23
23
|
export type AgentRecordStatus =
|
|
24
24
|
| "queued"
|
|
@@ -8,12 +8,12 @@ import {
|
|
|
8
8
|
type AgentSessionEvent,
|
|
9
9
|
type SettingsManager,
|
|
10
10
|
} from "@earendil-works/pi-coding-agent";
|
|
11
|
-
import type { AgentConfigLookup } from "
|
|
12
|
-
import {
|
|
13
|
-
import
|
|
14
|
-
import type {
|
|
15
|
-
import { type AssemblerIO, assembleSessionConfig } from "
|
|
16
|
-
import type { ShellExec, SubagentType, ThinkingLevel } from "
|
|
11
|
+
import type { AgentConfigLookup } from "#src/config/agent-types";
|
|
12
|
+
import type { ParentSnapshot } from "#src/lifecycle/parent-snapshot";
|
|
13
|
+
import { extractText } from "#src/session/context";
|
|
14
|
+
import type { EnvInfo } from "#src/session/env";
|
|
15
|
+
import { type AssemblerIO, assembleSessionConfig } from "#src/session/session-config";
|
|
16
|
+
import type { ShellExec, SubagentType, ThinkingLevel } from "#src/types";
|
|
17
17
|
|
|
18
18
|
/** Names of tools registered by this extension that subagents must NOT inherit. */
|
|
19
19
|
const EXCLUDED_TOOL_NAMES = ["Agent", "get_subagent_result", "steer_subagent"];
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
6
|
-
import { buildParentContext } from "
|
|
6
|
+
import { buildParentContext } from "#src/session/context";
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Plain data snapshot of the parent session state captured at spawn time.
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* cleanupResult is recorded once at completion or error — it is not set at construction.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import type { WorktreeCleanupResult, WorktreeInfo } from "
|
|
9
|
+
import type { WorktreeCleanupResult, WorktreeInfo } from "#src/lifecycle/worktree";
|
|
10
10
|
|
|
11
11
|
export type { WorktreeCleanupResult, WorktreeInfo };
|
|
12
12
|
|
|
@@ -11,7 +11,7 @@ import { randomUUID } from "node:crypto";
|
|
|
11
11
|
import { existsSync } from "node:fs";
|
|
12
12
|
import { tmpdir } from "node:os";
|
|
13
13
|
import { join } from "node:path";
|
|
14
|
-
import { debugLog } from "
|
|
14
|
+
import { debugLog } from "#src/debug";
|
|
15
15
|
|
|
16
16
|
export interface WorktreeInfo {
|
|
17
17
|
/** Absolute path to the worktree directory. */
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { debugLog } from "
|
|
2
|
-
import
|
|
3
|
-
import type {
|
|
4
|
-
import {
|
|
1
|
+
import { debugLog } from "#src/debug";
|
|
2
|
+
import { getLifetimeTotal, getSessionContextPercent } from "#src/lifecycle/usage";
|
|
3
|
+
import type { AgentRecord } from "#src/types";
|
|
4
|
+
import type { AgentActivityTracker } from "#src/ui/agent-activity-tracker";
|
|
5
5
|
|
|
6
6
|
/** Details attached to custom notification messages for visual rendering. */
|
|
7
7
|
export interface NotificationDetails {
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* and resume() with a single direct subscription.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import type { CompactionInfo } from "
|
|
9
|
-
import type { AgentRecord } from "
|
|
8
|
+
import type { CompactionInfo } from "#src/lifecycle/agent-manager";
|
|
9
|
+
import type { AgentRecord } from "#src/lifecycle/agent-record";
|
|
10
10
|
|
|
11
11
|
/** Narrow session interface — only the subscribe method needed by the observer. */
|
|
12
12
|
interface SubscribableSession {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Text } from "@earendil-works/pi-tui";
|
|
2
|
-
import type { NotificationDetails } from "
|
|
3
|
-
import { formatMs, formatTokens, formatTurns } from "
|
|
2
|
+
import type { NotificationDetails } from "#src/observation/notification";
|
|
3
|
+
import { formatMs, formatTokens, formatTurns } from "#src/ui/display";
|
|
4
4
|
|
|
5
5
|
/** Narrow theme interface — only the methods the renderer actually calls. */
|
|
6
6
|
interface RendererTheme {
|
package/src/runtime.ts
CHANGED
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
* Follows the same pattern as pi-permission-system's ExtensionRuntime.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import type { AgentActivityTracker } from "
|
|
10
|
-
import type { UICtx } from "
|
|
9
|
+
import type { AgentActivityTracker } from "#src/ui/agent-activity-tracker";
|
|
10
|
+
import type { UICtx } from "#src/ui/agent-widget";
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* Narrow widget interface consumed by SubagentRuntime delegation methods.
|
|
@@ -6,11 +6,11 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
9
|
-
import type {
|
|
10
|
-
import
|
|
11
|
-
import {
|
|
12
|
-
import type {
|
|
13
|
-
import type { AgentRecord } from "
|
|
9
|
+
import type { ParentSnapshot } from "#src/lifecycle/parent-snapshot";
|
|
10
|
+
import { buildParentSnapshot } from "#src/lifecycle/parent-snapshot";
|
|
11
|
+
import type { SubagentRecord, SubagentsService } from "#src/service/service";
|
|
12
|
+
import type { ModelRegistry } from "#src/session/model-resolver";
|
|
13
|
+
import type { AgentRecord } from "#src/types";
|
|
14
14
|
|
|
15
15
|
/** Narrow interface for the AgentManager — avoids coupling to the concrete class. */
|
|
16
16
|
export interface AgentManagerLike {
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* env.ts — Detect environment info (git, platform) for subagent system prompts.
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import { debugLog } from "
|
|
6
|
-
import type { ShellExec } from "
|
|
5
|
+
import { debugLog } from "#src/debug";
|
|
6
|
+
import type { ShellExec } from "#src/types";
|
|
7
7
|
|
|
8
8
|
export interface EnvInfo {
|
|
9
9
|
isGitRepo: boolean;
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
import { existsSync, lstatSync, mkdirSync, readFileSync } from "node:fs";
|
|
11
11
|
import { homedir } from "node:os";
|
|
12
12
|
import { join, } from "node:path";
|
|
13
|
-
import { debugLog } from "
|
|
14
|
-
import type { MemoryScope } from "
|
|
13
|
+
import { debugLog } from "#src/debug";
|
|
14
|
+
import type { MemoryScope } from "#src/types";
|
|
15
15
|
|
|
16
16
|
/** Maximum lines to read from MEMORY.md */
|
|
17
17
|
const MAX_MEMORY_LINES = 200;
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* prompts.ts — System prompt builder for agents.
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import type { EnvInfo } from "
|
|
6
|
-
import type { AgentPromptConfig } from "
|
|
5
|
+
import type { EnvInfo } from "#src/session/env";
|
|
6
|
+
import type { AgentPromptConfig } from "#src/types";
|
|
7
7
|
|
|
8
8
|
/** Extra sections to inject into the system prompt (memory, skills, etc.). */
|
|
9
9
|
export interface PromptExtras {
|
|
@@ -14,16 +14,16 @@ import {
|
|
|
14
14
|
type AgentConfigLookup,
|
|
15
15
|
getMemoryToolNames,
|
|
16
16
|
getReadOnlyMemoryToolNames,
|
|
17
|
-
} from "
|
|
18
|
-
import type { EnvInfo } from "
|
|
19
|
-
import type { PromptExtras } from "
|
|
20
|
-
import type { PreloadedSkill } from "
|
|
17
|
+
} from "#src/config/agent-types";
|
|
18
|
+
import type { EnvInfo } from "#src/session/env";
|
|
19
|
+
import type { PromptExtras } from "#src/session/prompts";
|
|
20
|
+
import type { PreloadedSkill } from "#src/session/skill-loader";
|
|
21
21
|
import type {
|
|
22
22
|
AgentPromptConfig,
|
|
23
23
|
MemoryScope,
|
|
24
24
|
SubagentType,
|
|
25
25
|
ThinkingLevel,
|
|
26
|
-
} from "
|
|
26
|
+
} from "#src/types";
|
|
27
27
|
|
|
28
28
|
// ── Public interfaces ────────────────────────────────────────────────────────
|
|
29
29
|
|
|
@@ -23,8 +23,8 @@ import { existsSync, readdirSync } from "node:fs";
|
|
|
23
23
|
import { homedir } from "node:os";
|
|
24
24
|
import { join } from "node:path";
|
|
25
25
|
import { getAgentDir } from "@earendil-works/pi-coding-agent";
|
|
26
|
-
import { debugLog } from "
|
|
27
|
-
import { isSymlink, isUnsafeName, safeReadFile } from "
|
|
26
|
+
import { debugLog } from "#src/debug";
|
|
27
|
+
import { isSymlink, isUnsafeName, safeReadFile } from "#src/session/memory";
|
|
28
28
|
|
|
29
29
|
export interface PreloadedSkill {
|
|
30
30
|
name: string;
|
package/src/tools/agent-tool.ts
CHANGED
|
@@ -1,24 +1,23 @@
|
|
|
1
1
|
import type { AgentToolResult } from "@earendil-works/pi-coding-agent";
|
|
2
2
|
import { Text } from "@earendil-works/pi-tui";
|
|
3
3
|
import { Type } from "@sinclair/typebox";
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import type { ParentSnapshot } from "
|
|
7
|
-
|
|
8
|
-
import
|
|
9
|
-
import {
|
|
10
|
-
import { type
|
|
4
|
+
import { AgentTypeRegistry } from "#src/config/agent-types";
|
|
5
|
+
import type { AgentSpawnConfig } from "#src/lifecycle/agent-manager";
|
|
6
|
+
import type { ParentSnapshot } from "#src/lifecycle/parent-snapshot";
|
|
7
|
+
import { spawnBackground } from "#src/tools/background-spawner";
|
|
8
|
+
import { runForeground } from "#src/tools/foreground-runner";
|
|
9
|
+
import { buildDetails, buildTypeListText, textResult } from "#src/tools/helpers";
|
|
10
|
+
import { type ModelInfo, resolveSpawnConfig } from "#src/tools/spawn-config";
|
|
11
|
+
import type { AgentRecord } from "#src/types";
|
|
12
|
+
import { AgentActivityTracker } from "#src/ui/agent-activity-tracker";
|
|
13
|
+
import { type UICtx } from "#src/ui/agent-widget";
|
|
11
14
|
import {
|
|
12
15
|
type AgentDetails,
|
|
13
16
|
formatMs,
|
|
14
17
|
formatTurns,
|
|
15
18
|
getDisplayName,
|
|
16
19
|
SPINNER,
|
|
17
|
-
} from "
|
|
18
|
-
import { spawnBackground } from "./background-spawner.js";
|
|
19
|
-
import { runForeground } from "./foreground-runner.js";
|
|
20
|
-
import { buildDetails, buildTypeListText, textResult } from "./helpers.js";
|
|
21
|
-
import { type ModelInfo, resolveSpawnConfig } from "./spawn-config.js";
|
|
20
|
+
} from "#src/ui/display";
|
|
22
21
|
|
|
23
22
|
// ---- Deps interface ----
|
|
24
23
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type { AgentSpawnConfig } from "
|
|
2
|
-
import type { ParentSnapshot } from "
|
|
3
|
-
import type {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import type {
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
1
|
+
import type { AgentSpawnConfig } from "#src/lifecycle/agent-manager";
|
|
2
|
+
import type { ParentSnapshot } from "#src/lifecycle/parent-snapshot";
|
|
3
|
+
import type { AgentActivityAccess } from "#src/tools/agent-tool";
|
|
4
|
+
import { textResult } from "#src/tools/helpers";
|
|
5
|
+
import type { ResolvedSpawnConfig } from "#src/tools/spawn-config";
|
|
6
|
+
import type { AgentRecord } from "#src/types";
|
|
7
|
+
import { AgentActivityTracker } from "#src/ui/agent-activity-tracker";
|
|
8
|
+
import { subscribeUIObserver } from "#src/ui/ui-observer";
|
|
9
9
|
|
|
10
10
|
/** Narrow manager interface for the background spawner. */
|
|
11
11
|
export interface BackgroundManagerDeps {
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import type { AgentToolResult } from "@earendil-works/pi-coding-agent";
|
|
2
|
-
import type { AgentSpawnConfig } from "
|
|
3
|
-
import type { ParentSnapshot } from "
|
|
4
|
-
import type {
|
|
5
|
-
import { AgentActivityTracker } from "../ui/agent-activity-tracker.js";
|
|
6
|
-
import {
|
|
7
|
-
type AgentDetails,
|
|
8
|
-
describeActivity,
|
|
9
|
-
formatMs,
|
|
10
|
-
SPINNER,
|
|
11
|
-
} from "../ui/display.js";
|
|
12
|
-
import { subscribeUIObserver } from "../ui/ui-observer.js";
|
|
13
|
-
import type { AgentActivityAccess } from "./agent-tool.js";
|
|
2
|
+
import type { AgentSpawnConfig } from "#src/lifecycle/agent-manager";
|
|
3
|
+
import type { ParentSnapshot } from "#src/lifecycle/parent-snapshot";
|
|
4
|
+
import type { AgentActivityAccess } from "#src/tools/agent-tool";
|
|
14
5
|
import {
|
|
15
6
|
buildDetails,
|
|
16
7
|
formatLifetimeTokens,
|
|
17
8
|
getStatusNote,
|
|
18
9
|
textResult,
|
|
19
|
-
} from "
|
|
20
|
-
import type { ResolvedSpawnConfig } from "
|
|
10
|
+
} from "#src/tools/helpers";
|
|
11
|
+
import type { ResolvedSpawnConfig } from "#src/tools/spawn-config";
|
|
12
|
+
import type { AgentRecord } from "#src/types";
|
|
13
|
+
import { AgentActivityTracker } from "#src/ui/agent-activity-tracker";
|
|
14
|
+
import {
|
|
15
|
+
type AgentDetails,
|
|
16
|
+
describeActivity,
|
|
17
|
+
formatMs,
|
|
18
|
+
SPINNER,
|
|
19
|
+
} from "#src/ui/display";
|
|
20
|
+
import { subscribeUIObserver } from "#src/ui/ui-observer";
|
|
21
21
|
|
|
22
22
|
/** Narrow manager interface for the foreground runner. */
|
|
23
23
|
export interface ForegroundManagerDeps {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { AgentSession } from "@earendil-works/pi-coding-agent";
|
|
2
2
|
import { Type } from "@sinclair/typebox";
|
|
3
|
-
import type { AgentConfigLookup } from "
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
3
|
+
import type { AgentConfigLookup } from "#src/config/agent-types";
|
|
4
|
+
import { getSessionContextPercent } from "#src/lifecycle/usage";
|
|
5
|
+
import { formatLifetimeTokens, textResult } from "#src/tools/helpers";
|
|
6
|
+
import type { AgentRecord } from "#src/types";
|
|
7
|
+
import { formatDuration, getDisplayName } from "#src/ui/display";
|
|
8
8
|
|
|
9
9
|
/** Create the get_subagent_result tool definition (without Pi SDK wrapper). */
|
|
10
10
|
export function createGetResultTool(
|
package/src/tools/helpers.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { AgentConfigLookup } from "
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import type { AgentConfigLookup } from "#src/config/agent-types";
|
|
2
|
+
import { getLifetimeTotal, type LifetimeUsage } from "#src/lifecycle/usage";
|
|
3
|
+
import { AgentActivityTracker } from "#src/ui/agent-activity-tracker";
|
|
4
|
+
import { type AgentDetails, formatTokens } from "#src/ui/display";
|
|
5
5
|
|
|
6
6
|
/** Parenthetical status note for completed agent result text. */
|
|
7
7
|
export function getStatusNote(status: string): string {
|
|
@@ -7,17 +7,17 @@
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import type { Model } from "@earendil-works/pi-ai";
|
|
10
|
-
import {
|
|
11
|
-
import
|
|
12
|
-
import {
|
|
13
|
-
import { resolveInvocationModel } from "
|
|
14
|
-
import type { AgentInvocation, IsolationMode, SubagentType, ThinkingLevel } from "
|
|
10
|
+
import type { AgentTypeRegistry } from "#src/config/agent-types";
|
|
11
|
+
import { resolveAgentInvocationConfig } from "#src/config/invocation-config";
|
|
12
|
+
import { normalizeMaxTurns } from "#src/lifecycle/agent-runner";
|
|
13
|
+
import { resolveInvocationModel } from "#src/session/model-resolver";
|
|
14
|
+
import type { AgentInvocation, IsolationMode, SubagentType, ThinkingLevel } from "#src/types";
|
|
15
15
|
import {
|
|
16
16
|
type AgentDetails,
|
|
17
17
|
buildInvocationTags,
|
|
18
18
|
getDisplayName,
|
|
19
19
|
getPromptModeLabel,
|
|
20
|
-
} from "
|
|
20
|
+
} from "#src/ui/display";
|
|
21
21
|
|
|
22
22
|
/** Model info extracted from the parent session context. */
|
|
23
23
|
export interface ModelInfo {
|
package/src/tools/steer-tool.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { AgentSession } from "@earendil-works/pi-coding-agent";
|
|
2
2
|
import { Type } from "@sinclair/typebox";
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
3
|
+
import { getSessionContextPercent } from "#src/lifecycle/usage";
|
|
4
|
+
import { formatLifetimeTokens, textResult } from "#src/tools/helpers";
|
|
5
|
+
import type { AgentRecord } from "#src/types";
|
|
6
6
|
|
|
7
7
|
/** Create the steer_subagent tool definition (without Pi SDK wrapper). */
|
|
8
8
|
export function createSteerTool(
|
package/src/types.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import type { ThinkingLevel } from "@earendil-works/pi-ai";
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
export { AgentRecord } from "
|
|
8
|
+
export { AgentRecord } from "#src/lifecycle/agent-record";
|
|
9
9
|
export type { ThinkingLevel };
|
|
10
10
|
|
|
11
11
|
/** Agent type: any string name (built-in defaults or user-defined). */
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* in `ui-observer.ts`. Callers use named transition methods; readers use read-only accessors.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import type { SessionLike } from "
|
|
8
|
+
import type { SessionLike } from "#src/lifecycle/usage";
|
|
9
9
|
|
|
10
10
|
/** Per-agent live activity state with explicit transition methods and read-only accessors. */
|
|
11
11
|
export class AgentActivityTracker {
|
|
@@ -7,10 +7,10 @@
|
|
|
7
7
|
|
|
8
8
|
import { join } from "node:path";
|
|
9
9
|
|
|
10
|
-
import type { AgentTypeRegistry } from "
|
|
11
|
-
import type { AgentConfig } from "
|
|
12
|
-
import type { AgentFileOps } from "
|
|
13
|
-
import type { MenuUI } from "
|
|
10
|
+
import type { AgentTypeRegistry } from "#src/config/agent-types";
|
|
11
|
+
import type { AgentConfig } from "#src/types";
|
|
12
|
+
import type { AgentFileOps } from "#src/ui/agent-file-ops";
|
|
13
|
+
import type { MenuUI } from "#src/ui/agent-menu";
|
|
14
14
|
|
|
15
15
|
// ---- Factory ----
|
|
16
16
|
|
|
@@ -7,11 +7,11 @@
|
|
|
7
7
|
|
|
8
8
|
import { join } from "node:path";
|
|
9
9
|
|
|
10
|
-
import { BUILTIN_TOOL_NAMES } from "
|
|
11
|
-
import type { ParentSnapshot } from "
|
|
12
|
-
import type { AgentRecord } from "
|
|
13
|
-
import type { AgentFileOps } from "
|
|
14
|
-
import type { MenuUI } from "
|
|
10
|
+
import { BUILTIN_TOOL_NAMES } from "#src/config/agent-types";
|
|
11
|
+
import type { ParentSnapshot } from "#src/lifecycle/parent-snapshot";
|
|
12
|
+
import type { AgentRecord } from "#src/types";
|
|
13
|
+
import type { AgentFileOps } from "#src/ui/agent-file-ops";
|
|
14
|
+
import type { MenuUI } from "#src/ui/agent-menu";
|
|
15
15
|
|
|
16
16
|
// ---- Deps interface ----
|
|
17
17
|
|
package/src/ui/agent-menu.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { wrapTextWithAnsi } from "@earendil-works/pi-tui";
|
|
2
|
-
import { AgentTypeRegistry } from "
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
5
|
-
import type { AgentConfig, AgentRecord } from "
|
|
6
|
-
import type { AgentActivityTracker } from "
|
|
7
|
-
import { createAgentConfigEditor } from "
|
|
8
|
-
import { createAgentCreationWizard } from "
|
|
9
|
-
import type { AgentFileOps } from "
|
|
10
|
-
import { formatDuration, getDisplayName } from "
|
|
2
|
+
import { AgentTypeRegistry } from "#src/config/agent-types";
|
|
3
|
+
import type { ParentSnapshot } from "#src/lifecycle/parent-snapshot";
|
|
4
|
+
import type { ModelRegistry } from "#src/session/model-resolver";
|
|
5
|
+
import type { AgentConfig, AgentRecord } from "#src/types";
|
|
6
|
+
import type { AgentActivityTracker } from "#src/ui/agent-activity-tracker";
|
|
7
|
+
import { createAgentConfigEditor } from "#src/ui/agent-config-editor";
|
|
8
|
+
import { createAgentCreationWizard } from "#src/ui/agent-creation-wizard";
|
|
9
|
+
import type { AgentFileOps } from "#src/ui/agent-file-ops";
|
|
10
|
+
import { formatDuration, getDisplayName } from "#src/ui/display";
|
|
11
11
|
|
|
12
12
|
// ---- Deps interface ----
|
|
13
13
|
|
|
@@ -247,7 +247,7 @@ export function createAgentsMenuHandler({
|
|
|
247
247
|
}
|
|
248
248
|
|
|
249
249
|
const { ConversationViewer, VIEWPORT_HEIGHT_PCT } = await import(
|
|
250
|
-
"./conversation-viewer
|
|
250
|
+
"./conversation-viewer"
|
|
251
251
|
);
|
|
252
252
|
const activity = agentActivity.get(record.id);
|
|
253
253
|
|
package/src/ui/agent-widget.ts
CHANGED
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
* Uses the callback form of setWidget for themed rendering.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import
|
|
9
|
-
import {
|
|
10
|
-
import type { AgentActivityTracker } from "
|
|
11
|
-
import { ERROR_STATUSES, type Theme } from "
|
|
12
|
-
import { renderWidgetLines } from "
|
|
8
|
+
import { AgentTypeRegistry } from "#src/config/agent-types";
|
|
9
|
+
import type { AgentManager } from "#src/lifecycle/agent-manager";
|
|
10
|
+
import type { AgentActivityTracker } from "#src/ui/agent-activity-tracker";
|
|
11
|
+
import { ERROR_STATUSES, type Theme } from "#src/ui/display";
|
|
12
|
+
import { renderWidgetLines } from "#src/ui/widget-renderer";
|
|
13
13
|
|
|
14
14
|
// ---- Types ----
|
|
15
15
|
|
|
@@ -7,12 +7,12 @@
|
|
|
7
7
|
|
|
8
8
|
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
|
-
import type { AgentConfigLookup } from "
|
|
11
|
-
import {
|
|
12
|
-
import
|
|
13
|
-
import {
|
|
14
|
-
import type { AgentActivityTracker } from "
|
|
15
|
-
import { buildInvocationTags, describeActivity, formatDuration, formatSessionTokens, getDisplayName, getPromptModeLabel, type Theme } from "
|
|
10
|
+
import type { AgentConfigLookup } from "#src/config/agent-types";
|
|
11
|
+
import { getLifetimeTotal, getSessionContextPercent } from "#src/lifecycle/usage";
|
|
12
|
+
import { extractText } from "#src/session/context";
|
|
13
|
+
import type { AgentRecord } from "#src/types";
|
|
14
|
+
import type { AgentActivityTracker } from "#src/ui/agent-activity-tracker";
|
|
15
|
+
import { buildInvocationTags, describeActivity, formatDuration, formatSessionTokens, getDisplayName, getPromptModeLabel, type Theme } from "#src/ui/display";
|
|
16
16
|
|
|
17
17
|
// ── Local message-shape types ───────────────────────────────────────────────
|
|
18
18
|
// The Pi SDK does not export narrow types for all message content variants.
|