@gotgenes/pi-subagents 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/.markdownlint-cli2.yaml +19 -0
- package/.prettierignore +5 -0
- package/.release-please-manifest.json +3 -0
- package/AGENTS.md +85 -0
- package/CHANGELOG.md +495 -0
- package/LICENSE +21 -0
- package/README.md +528 -0
- package/dist/agent-manager.d.ts +108 -0
- package/dist/agent-manager.js +390 -0
- package/dist/agent-runner.d.ts +93 -0
- package/dist/agent-runner.js +428 -0
- package/dist/agent-types.d.ts +48 -0
- package/dist/agent-types.js +136 -0
- package/dist/context.d.ts +12 -0
- package/dist/context.js +56 -0
- package/dist/cross-extension-rpc.d.ts +46 -0
- package/dist/cross-extension-rpc.js +54 -0
- package/dist/custom-agents.d.ts +14 -0
- package/dist/custom-agents.js +127 -0
- package/dist/default-agents.d.ts +7 -0
- package/dist/default-agents.js +119 -0
- package/dist/env.d.ts +6 -0
- package/dist/env.js +28 -0
- package/dist/group-join.d.ts +32 -0
- package/dist/group-join.js +116 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +1731 -0
- package/dist/invocation-config.d.ts +22 -0
- package/dist/invocation-config.js +15 -0
- package/dist/memory.d.ts +49 -0
- package/dist/memory.js +151 -0
- package/dist/model-resolver.d.ts +19 -0
- package/dist/model-resolver.js +62 -0
- package/dist/output-file.d.ts +24 -0
- package/dist/output-file.js +86 -0
- package/dist/prompts.d.ts +29 -0
- package/dist/prompts.js +72 -0
- package/dist/schedule-store.d.ts +36 -0
- package/dist/schedule-store.js +144 -0
- package/dist/schedule.d.ts +109 -0
- package/dist/schedule.js +338 -0
- package/dist/settings.d.ts +66 -0
- package/dist/settings.js +130 -0
- package/dist/skill-loader.d.ts +24 -0
- package/dist/skill-loader.js +93 -0
- package/dist/types.d.ts +164 -0
- package/dist/types.js +5 -0
- package/dist/ui/agent-widget.d.ts +134 -0
- package/dist/ui/agent-widget.js +451 -0
- package/dist/ui/conversation-viewer.d.ts +35 -0
- package/dist/ui/conversation-viewer.js +252 -0
- package/dist/ui/schedule-menu.d.ts +16 -0
- package/dist/ui/schedule-menu.js +95 -0
- package/dist/usage.d.ts +50 -0
- package/dist/usage.js +49 -0
- package/dist/worktree.d.ts +36 -0
- package/dist/worktree.js +139 -0
- package/docs/decisions/0001-deferred-patches.md +75 -0
- package/package.json +68 -0
- package/prek.toml +24 -0
- package/release-please-config.json +22 -0
- package/src/agent-manager.ts +482 -0
- package/src/agent-runner.ts +625 -0
- package/src/agent-types.ts +164 -0
- package/src/context.ts +58 -0
- package/src/cross-extension-rpc.ts +95 -0
- package/src/custom-agents.ts +136 -0
- package/src/default-agents.ts +123 -0
- package/src/env.ts +33 -0
- package/src/group-join.ts +141 -0
- package/src/index.ts +1894 -0
- package/src/invocation-config.ts +40 -0
- package/src/memory.ts +165 -0
- package/src/model-resolver.ts +81 -0
- package/src/output-file.ts +96 -0
- package/src/prompts.ts +105 -0
- package/src/schedule-store.ts +143 -0
- package/src/schedule.ts +365 -0
- package/src/settings.ts +186 -0
- package/src/skill-loader.ts +102 -0
- package/src/types.ts +176 -0
- package/src/ui/agent-widget.ts +533 -0
- package/src/ui/conversation-viewer.ts +261 -0
- package/src/ui/schedule-menu.ts +104 -0
- package/src/usage.ts +60 -0
- package/src/worktree.ts +162 -0
package/src/types.ts
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* types.ts — Type definitions for the subagent system.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import type { ThinkingLevel } from "@earendil-works/pi-ai";
|
|
6
|
+
import type { AgentSession } from "@earendil-works/pi-coding-agent";
|
|
7
|
+
import type { LifetimeUsage } from "./usage.js";
|
|
8
|
+
|
|
9
|
+
export type { ThinkingLevel };
|
|
10
|
+
|
|
11
|
+
/** Agent type: any string name (built-in defaults or user-defined). */
|
|
12
|
+
export type SubagentType = string;
|
|
13
|
+
|
|
14
|
+
/** Names of the three embedded default agents. */
|
|
15
|
+
export const DEFAULT_AGENT_NAMES = ["general-purpose", "Explore", "Plan"] as const;
|
|
16
|
+
|
|
17
|
+
/** Memory scope for persistent agent memory. */
|
|
18
|
+
export type MemoryScope = "user" | "project" | "local";
|
|
19
|
+
|
|
20
|
+
/** Isolation mode for agent execution. */
|
|
21
|
+
export type IsolationMode = "worktree";
|
|
22
|
+
|
|
23
|
+
/** Unified agent configuration — used for both default and user-defined agents. */
|
|
24
|
+
export interface AgentConfig {
|
|
25
|
+
name: string;
|
|
26
|
+
displayName?: string;
|
|
27
|
+
description: string;
|
|
28
|
+
builtinToolNames?: string[];
|
|
29
|
+
/** Tool denylist — these tools are removed even if `builtinToolNames` or extensions include them. */
|
|
30
|
+
disallowedTools?: string[];
|
|
31
|
+
/** true = inherit all, string[] = only listed, false = none */
|
|
32
|
+
extensions: true | string[] | false;
|
|
33
|
+
/** true = inherit all, string[] = only listed, false = none */
|
|
34
|
+
skills: true | string[] | false;
|
|
35
|
+
model?: string;
|
|
36
|
+
thinking?: ThinkingLevel;
|
|
37
|
+
maxTurns?: number;
|
|
38
|
+
systemPrompt: string;
|
|
39
|
+
promptMode: "replace" | "append";
|
|
40
|
+
/** Default for spawn: fork parent conversation. undefined = caller decides. */
|
|
41
|
+
inheritContext?: boolean;
|
|
42
|
+
/** Default for spawn: run in background. undefined = caller decides. */
|
|
43
|
+
runInBackground?: boolean;
|
|
44
|
+
/** Default for spawn: no extension tools. undefined = caller decides. */
|
|
45
|
+
isolated?: boolean;
|
|
46
|
+
/** Persistent memory scope — agents with memory get a persistent directory and MEMORY.md */
|
|
47
|
+
memory?: MemoryScope;
|
|
48
|
+
/** Isolation mode — "worktree" runs the agent in a temporary git worktree */
|
|
49
|
+
isolation?: IsolationMode;
|
|
50
|
+
/** true = this is an embedded default agent (informational) */
|
|
51
|
+
isDefault?: boolean;
|
|
52
|
+
/** false = agent is hidden from the registry */
|
|
53
|
+
enabled?: boolean;
|
|
54
|
+
/** Where this agent was loaded from */
|
|
55
|
+
source?: "default" | "project" | "global";
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export type JoinMode = 'async' | 'group' | 'smart';
|
|
59
|
+
|
|
60
|
+
export interface AgentRecord {
|
|
61
|
+
id: string;
|
|
62
|
+
type: SubagentType;
|
|
63
|
+
description: string;
|
|
64
|
+
status: "queued" | "running" | "completed" | "steered" | "aborted" | "stopped" | "error";
|
|
65
|
+
result?: string;
|
|
66
|
+
error?: string;
|
|
67
|
+
toolUses: number;
|
|
68
|
+
startedAt: number;
|
|
69
|
+
completedAt?: number;
|
|
70
|
+
session?: AgentSession;
|
|
71
|
+
abortController?: AbortController;
|
|
72
|
+
promise?: Promise<string>;
|
|
73
|
+
groupId?: string;
|
|
74
|
+
joinMode?: JoinMode;
|
|
75
|
+
/** Set when result was already consumed via get_subagent_result — suppresses completion notification. */
|
|
76
|
+
resultConsumed?: boolean;
|
|
77
|
+
/** Steering messages queued before the session was ready. */
|
|
78
|
+
pendingSteers?: string[];
|
|
79
|
+
/** Worktree info if the agent is running in an isolated worktree. */
|
|
80
|
+
worktree?: { path: string; branch: string };
|
|
81
|
+
/** Worktree cleanup result after agent completion. */
|
|
82
|
+
worktreeResult?: { hasChanges: boolean; branch?: string };
|
|
83
|
+
/** The tool_use_id from the original Agent tool call. */
|
|
84
|
+
toolCallId?: string;
|
|
85
|
+
/** Path to the streaming output transcript file. */
|
|
86
|
+
outputFile?: string;
|
|
87
|
+
/** Cleanup function for the output file stream subscription. */
|
|
88
|
+
outputCleanup?: () => void;
|
|
89
|
+
/**
|
|
90
|
+
* Lifetime usage breakdown, accumulated via `message_end` events. Survives
|
|
91
|
+
* compaction. Total = input + output + cacheWrite (cacheRead deliberately
|
|
92
|
+
* excluded — see issue #38). Initialized to zeros at spawn.
|
|
93
|
+
*/
|
|
94
|
+
lifetimeUsage: LifetimeUsage;
|
|
95
|
+
/** Number of times this agent's session has compacted. Initialized to 0 at spawn. */
|
|
96
|
+
compactionCount: number;
|
|
97
|
+
/** Resolved spawn params, captured for UI display. Fixed at spawn time. */
|
|
98
|
+
invocation?: AgentInvocation;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export interface AgentInvocation {
|
|
102
|
+
/** Short display name, e.g. "haiku" — only set when different from parent. */
|
|
103
|
+
modelName?: string;
|
|
104
|
+
thinking?: ThinkingLevel;
|
|
105
|
+
maxTurns?: number;
|
|
106
|
+
isolated?: boolean;
|
|
107
|
+
inheritContext?: boolean;
|
|
108
|
+
runInBackground?: boolean;
|
|
109
|
+
isolation?: IsolationMode;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/** Details attached to custom notification messages for visual rendering. */
|
|
113
|
+
export interface NotificationDetails {
|
|
114
|
+
id: string;
|
|
115
|
+
description: string;
|
|
116
|
+
status: string;
|
|
117
|
+
toolUses: number;
|
|
118
|
+
turnCount: number;
|
|
119
|
+
maxTurns?: number;
|
|
120
|
+
totalTokens: number;
|
|
121
|
+
durationMs: number;
|
|
122
|
+
outputFile?: string;
|
|
123
|
+
error?: string;
|
|
124
|
+
resultPreview: string;
|
|
125
|
+
/** Additional agents in a group notification. */
|
|
126
|
+
others?: NotificationDetails[];
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export interface EnvInfo {
|
|
130
|
+
isGitRepo: boolean;
|
|
131
|
+
branch: string;
|
|
132
|
+
platform: string;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* A subagent spawn registered to fire on a schedule.
|
|
137
|
+
*
|
|
138
|
+
* Stored at `<cwd>/.pi/subagent-schedules/<sessionId>.json`. Session-scoped:
|
|
139
|
+
* survives `/resume` but resets on `/new`, mirroring pi-chonky-tasks.
|
|
140
|
+
*/
|
|
141
|
+
export interface ScheduledSubagent {
|
|
142
|
+
id: string;
|
|
143
|
+
/** Unique within store. Defaults to `description`. */
|
|
144
|
+
name: string;
|
|
145
|
+
description: string;
|
|
146
|
+
/** Raw user input — cron expr | "+10m" | ISO | "5m". */
|
|
147
|
+
schedule: string;
|
|
148
|
+
scheduleType: "cron" | "once" | "interval";
|
|
149
|
+
/** Computed at create time for interval/once. */
|
|
150
|
+
intervalMs?: number;
|
|
151
|
+
|
|
152
|
+
// spawn params (subset of Agent tool params; no inherit_context, no resume)
|
|
153
|
+
subagent_type: SubagentType;
|
|
154
|
+
prompt: string;
|
|
155
|
+
model?: string;
|
|
156
|
+
thinking?: ThinkingLevel;
|
|
157
|
+
max_turns?: number;
|
|
158
|
+
isolated?: boolean;
|
|
159
|
+
isolation?: IsolationMode;
|
|
160
|
+
|
|
161
|
+
// state
|
|
162
|
+
enabled: boolean;
|
|
163
|
+
/** ISO timestamp. */
|
|
164
|
+
createdAt: string;
|
|
165
|
+
lastRun?: string;
|
|
166
|
+
lastStatus?: "success" | "error" | "running";
|
|
167
|
+
/** Refreshed on every fire and on store load. */
|
|
168
|
+
nextRun?: string;
|
|
169
|
+
runCount: number;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
export interface ScheduleStoreData {
|
|
173
|
+
/** For future migrations. */
|
|
174
|
+
version: 1;
|
|
175
|
+
jobs: ScheduledSubagent[];
|
|
176
|
+
}
|