@giladbarnea/pi-simple-team 1.0.21 → 1.0.23
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 +46 -21
- package/child-tools.ts +29 -3
- package/index.ts +520 -36
- package/package.json +1 -1
- package/system-prompt.ts +1 -1
- package/team-registry.ts +300 -0
- package/team-ui.ts +342 -0
package/README.md
CHANGED
|
@@ -41,6 +41,14 @@ Not scheduling a meeting.
|
|
|
41
41
|
Tell your main agent:
|
|
42
42
|
> Spawn a team.
|
|
43
43
|
|
|
44
|
+
### Watch a live team with `/team`.
|
|
45
|
+
|
|
46
|
+
`/team` is for you, not another agent tool. It gives you a live view of the room without turning the main agent into a status relay.
|
|
47
|
+
|
|
48
|
+
The command opens a read-only overlay with recent statuses, messages, and a separate event log. With no teams, it shows an empty state. With one team, it opens that team directly. With several teams, it starts with a selector.
|
|
49
|
+
|
|
50
|
+
The fixed layout keeps the latest content in view as work arrives, without scrolling or jumping around. It is an overview of the room, not a teammate drill-down or transcript.
|
|
51
|
+
|
|
44
52
|
### Throw a team at something hard.
|
|
45
53
|
|
|
46
54
|
The team takes the shape of the mission.
|
|
@@ -155,13 +163,13 @@ Main agent knows its own and everyone else's too.
|
|
|
155
163
|
- 17:32:01: Release teammate sets status: "Ran `git add .`, preparing commit and push."
|
|
156
164
|
- 17:32:02: Scout immediately interrupts. Key never leaves the machine. Developer keeps their job.
|
|
157
165
|
|
|
158
|
-
### 📡
|
|
166
|
+
### 📡 Live observability without a second history.
|
|
159
167
|
|
|
160
|
-
|
|
168
|
+
While a team runs, `teamlog` exposes a timestamped, filterable timeline of messages, tool calls, and lifecycle events.
|
|
161
169
|
|
|
162
|
-
|
|
170
|
+
That live timeline stays in parent-process memory and starts fresh after a resume. Pi session JSONL files are the canonical conversation history.
|
|
163
171
|
|
|
164
|
-
|
|
172
|
+
`pi-simple-team` does not persist a separate parent-runtime log or duplicate `teamlog` data.
|
|
165
173
|
|
|
166
174
|
<br>
|
|
167
175
|
|
|
@@ -175,6 +183,24 @@ Useful for tracing a failure *across* teammates—without asking anyone to recon
|
|
|
175
183
|
- Live view of the room.
|
|
176
184
|
- Talk directly with teammates.
|
|
177
185
|
|
|
186
|
+
### 🧱 Teammates are durable Pi sessions.
|
|
187
|
+
|
|
188
|
+
A teammate is a normal Pi session with a team attachment and an optional live runtime. The attachment adds its team prompt, roster, and communication tools.
|
|
189
|
+
|
|
190
|
+
Each team ID is `{origin-main-session-id}-{team-name}`. `team_list` discovers active and dormant teams from the same canonical project directory.
|
|
191
|
+
|
|
192
|
+
`team_shutdown` stops every live runtime and leaves the team dormant. Its manifest expires after 30 days, but expiration never deletes Pi session files.
|
|
193
|
+
|
|
194
|
+
`team_resume` starts all stopped teammates by default, or only selected teammates. Resume uses RPC unless `showOnHerdrPanes` is explicitly set.
|
|
195
|
+
|
|
196
|
+
Pi creates a session path before it writes the session JSONL file. A teammate without a first assistant response therefore restarts empty.
|
|
197
|
+
|
|
198
|
+
A missing file that once held session history causes resume to fail. Persisted sessions restore their own model and thinking state from Pi.
|
|
199
|
+
|
|
200
|
+
`team_add` creates new RPC teammates only for a running team owned by the current main session.
|
|
201
|
+
|
|
202
|
+
**One Pi session can have only one live runtime.** Pi does not lock session files against concurrent writers.
|
|
203
|
+
|
|
178
204
|
|
|
179
205
|
## Install
|
|
180
206
|
|
|
@@ -190,16 +216,16 @@ pi install npm:@giladbarnea/pi-simple-team
|
|
|
190
216
|
Kept minimal:
|
|
191
217
|
|
|
192
218
|
|
|
193
|
-
| Role | For | Tools
|
|
194
|
-
| -------------- | -------------- |
|
|
195
|
-
| **Main agent** | Team lifecycle | `team_spawn`, `team_shutdown` |
|
|
196
|
-
| | With team | `teamsend`
|
|
197
|
-
| | On team | `teamstatus`, `teamlog`
|
|
198
|
-
| | On everyone | `report_context_window`
|
|
199
|
-
| **Teammates** | With team | `teamsend`
|
|
200
|
-
| | With main | `teammain`
|
|
201
|
-
| | On self | `report_context_window`
|
|
202
|
-
| **Everyone** | For everyone | `teamstatus`
|
|
219
|
+
| Role | For | Tools |
|
|
220
|
+
| -------------- | -------------- | ---------------------------------------------------------------- |
|
|
221
|
+
| **Main agent** | Team lifecycle | `team_spawn`, `team_list`, `team_resume`, `team_add`, `team_shutdown` |
|
|
222
|
+
| | With team | `teamsend` |
|
|
223
|
+
| | On team | `teamstatus`, `teamlog` |
|
|
224
|
+
| | On everyone | `report_context_window` |
|
|
225
|
+
| **Teammates** | With team | `teamsend` |
|
|
226
|
+
| | With main | `teammain` |
|
|
227
|
+
| | On self | `report_context_window` |
|
|
228
|
+
| **Everyone** | For everyone | `teamstatus` |
|
|
203
229
|
|
|
204
230
|
|
|
205
231
|
---
|
|
@@ -211,14 +237,13 @@ Kept minimal:
|
|
|
211
237
|
**User involvement track:**
|
|
212
238
|
|
|
213
239
|
- [x] Herdr panes for teammates.
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
- [ ]
|
|
218
|
-
- [ ] 👋 Joining and steering teams.
|
|
219
|
-
- [ ] 🪄 Spawning teams directly.
|
|
240
|
+
- [x] `/team`: live, read-only team dashboard.
|
|
241
|
+
- [ ] Teammate drill-down and transcripts.
|
|
242
|
+
- [ ] Joining and steering teams from slash commands.
|
|
243
|
+
- [ ] Spawning teams directly from slash commands.
|
|
220
244
|
|
|
221
245
|
**Functional:**
|
|
222
246
|
|
|
223
|
-
- [
|
|
247
|
+
- [x] Resume all or selected teammates from a dormant team.
|
|
248
|
+
- [x] Add new teammates after a team has spawned.
|
|
224
249
|
- [ ] Main forces `/compact` on select teammate.
|
package/child-tools.ts
CHANGED
|
@@ -13,6 +13,7 @@ const visibleLifecycleRetryAttempts = 3;
|
|
|
13
13
|
export interface ChildRuntimeConfig {
|
|
14
14
|
callbackUrl: string;
|
|
15
15
|
callbackToken: string;
|
|
16
|
+
teamId?: string;
|
|
16
17
|
teamName: string;
|
|
17
18
|
teammateName: string;
|
|
18
19
|
visible: boolean;
|
|
@@ -36,10 +37,12 @@ function readParticipants(): string[] {
|
|
|
36
37
|
}
|
|
37
38
|
|
|
38
39
|
function readRequiredChildRuntimeConfig(): ChildRuntimeConfig {
|
|
40
|
+
const teamId = requiredEnvironmentVariable("PI_SIMPLE_TEAM_TEAM");
|
|
39
41
|
return {
|
|
40
42
|
callbackUrl: requiredEnvironmentVariable("PI_SIMPLE_TEAM_CALLBACK_URL"),
|
|
41
43
|
callbackToken: requiredEnvironmentVariable("PI_SIMPLE_TEAM_CALLBACK_TOKEN"),
|
|
42
|
-
|
|
44
|
+
teamId,
|
|
45
|
+
teamName: process.env.PI_SIMPLE_TEAM_TEAM_NAME ?? teamId,
|
|
43
46
|
teammateName: requiredEnvironmentVariable("PI_SIMPLE_TEAM_MEMBER"),
|
|
44
47
|
visible: process.env.PI_SIMPLE_TEAM_VISIBLE_CHILD === "1",
|
|
45
48
|
participants: readParticipants(),
|
|
@@ -57,7 +60,7 @@ async function callParent(config: ChildRuntimeConfig, tool: string, args: JsonRe
|
|
|
57
60
|
headers: { "content-type": "application/json" },
|
|
58
61
|
body: JSON.stringify({
|
|
59
62
|
token: config.callbackToken,
|
|
60
|
-
team: config.teamName,
|
|
63
|
+
team: config.teamId ?? config.teamName,
|
|
61
64
|
from: config.teammateName,
|
|
62
65
|
tool,
|
|
63
66
|
args,
|
|
@@ -226,7 +229,11 @@ function startVisibleChild(pi: ExtensionAPI, config: ChildRuntimeConfig): void {
|
|
|
226
229
|
if (!address || typeof address === "string") throw new Error("Visible teammate server did not get a port");
|
|
227
230
|
|
|
228
231
|
try {
|
|
229
|
-
await callParent(config, "visible_register", {
|
|
232
|
+
await callParent(config, "visible_register", {
|
|
233
|
+
url: `http://127.0.0.1:${address.port}/deliver`,
|
|
234
|
+
sessionId: context.sessionManager.getSessionId(),
|
|
235
|
+
sessionFile: context.sessionManager.getSessionFile(),
|
|
236
|
+
});
|
|
230
237
|
} catch (error) {
|
|
231
238
|
context.shutdown();
|
|
232
239
|
throw error;
|
|
@@ -248,6 +255,25 @@ function startVisibleChild(pi: ExtensionAPI, config: ChildRuntimeConfig): void {
|
|
|
248
255
|
|
|
249
256
|
export function registerChildTools(pi: ExtensionAPI, config: ChildRuntimeConfig): void {
|
|
250
257
|
pi.registerMessageRenderer(teamMessageType, (message, _options, theme) => renderTeamMessage(message, theme, getMarkdownTheme(), config.participants));
|
|
258
|
+
const startupRosterInstruction = `Participants: main, ${config.participants.join(", ")}.`;
|
|
259
|
+
pi.on("before_agent_start", async (event, context) => {
|
|
260
|
+
const teamContext = await callParent(config, "team_context", {}, context.signal);
|
|
261
|
+
const rawParticipants: unknown = teamContext.participants;
|
|
262
|
+
if (!Array.isArray(rawParticipants) || rawParticipants.some((participant: unknown) => typeof participant !== "string")) {
|
|
263
|
+
throw new Error("team runtime returned an invalid participant list");
|
|
264
|
+
}
|
|
265
|
+
const participants = rawParticipants as string[];
|
|
266
|
+
if (!event.systemPrompt.includes(startupRosterInstruction)) {
|
|
267
|
+
throw new Error("team runtime could not find its startup roster instruction");
|
|
268
|
+
}
|
|
269
|
+
config.participants.splice(0, config.participants.length, ...participants);
|
|
270
|
+
return {
|
|
271
|
+
systemPrompt: event.systemPrompt.replace(
|
|
272
|
+
startupRosterInstruction,
|
|
273
|
+
`Participants: main, ${participants.join(", ")}.`,
|
|
274
|
+
),
|
|
275
|
+
};
|
|
276
|
+
});
|
|
251
277
|
if (config.visible) startVisibleChild(pi, config);
|
|
252
278
|
|
|
253
279
|
pi.registerTool(
|