@giladbarnea/pi-simple-team 1.0.23 → 1.0.24
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 +59 -16
- package/child-tools.ts +3 -1
- package/index.ts +67 -19
- package/package.json +1 -1
- package/system-prompt.ts +12 -1
- package/team-registry.ts +2 -0
package/README.md
CHANGED
|
@@ -15,7 +15,9 @@
|
|
|
15
15
|
|
|
16
16
|
**No roles. No org chart. No mailboxes. No routing rules.**
|
|
17
17
|
|
|
18
|
-
`pi-simple-team` spawns a
|
|
18
|
+
`pi-simple-team` spawns a small team of Pi agents that can all talk to each other, like the responsible adults they are, **and then stays out of the way.**
|
|
19
|
+
|
|
20
|
+
Each team stays flat. When the work needs another room, an opted-in teammate can now open and manage teams of its own.
|
|
19
21
|
|
|
20
22
|
</div>
|
|
21
23
|
|
|
@@ -41,6 +43,38 @@ Not scheduling a meeting.
|
|
|
41
43
|
Tell your main agent:
|
|
42
44
|
> Spawn a team.
|
|
43
45
|
|
|
46
|
+
### Give one teammate a room of its own.
|
|
47
|
+
|
|
48
|
+
Most work fits one flat team. Some work contains a second problem that needs its own people and its own coordination loop.
|
|
49
|
+
|
|
50
|
+
Set `canOverseeOwnTeams: true` when you create that teammate:
|
|
51
|
+
|
|
52
|
+
```json
|
|
53
|
+
{
|
|
54
|
+
"name": "research-lead",
|
|
55
|
+
"prompt": "Map the product domain. Create a team for the database investigation.",
|
|
56
|
+
"model": "provider/model-id",
|
|
57
|
+
"canOverseeOwnTeams": true
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
That teammate stays in the parent team and becomes main for every team it creates. It gets the same team lifecycle, messaging, status, log, and context-window tools as the original main agent.
|
|
62
|
+
|
|
63
|
+
The boundary is strict. It can manage only teams created by its own Pi session. It cannot inspect or stop its parent team, sibling teams, or their teammates. The option defaults to `false`.
|
|
64
|
+
|
|
65
|
+
```mermaid
|
|
66
|
+
flowchart LR
|
|
67
|
+
main["main"] --> A["Team A"]
|
|
68
|
+
main --> B["Team B"]
|
|
69
|
+
main --> C["Team C"]
|
|
70
|
+
A --> A1["A1 · canOverseeOwnTeams"]
|
|
71
|
+
A1 --> A1a["A1 team 1"]
|
|
72
|
+
A1 --> A1b["A1 team 2"]
|
|
73
|
+
A1 --> A1c["A1 team 3"]
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
A room can open another room. It does not get the keys to the whole building.
|
|
77
|
+
|
|
44
78
|
### Watch a live team with `/team`.
|
|
45
79
|
|
|
46
80
|
`/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.
|
|
@@ -67,19 +101,19 @@ Main agent:
|
|
|
67
101
|
|
|
68
102
|
You:
|
|
69
103
|
> **Team goal:**
|
|
70
|
-
> 1.
|
|
104
|
+
> 1. Map all customer–product money streams in the database.
|
|
71
105
|
> 2. Feed this knowledge into the harness.
|
|
72
|
-
> 3.
|
|
106
|
+
> 3. Prove the data analysis agent passes the new evals.
|
|
73
107
|
>
|
|
74
108
|
> **Note:**
|
|
75
109
|
> - #1 and #3 are _loops._ Call them `1-map` and `3-eval`.
|
|
76
|
-
> - `1-map` and `3-eval` each gets a
|
|
110
|
+
> - `1-map` and `3-eval` each gets a teammate with `canOverseeOwnTeams: true`.
|
|
77
111
|
> - Each teammate spawns _its own team_ to loop on its task.
|
|
78
112
|
|
|
79
113
|
<br>
|
|
80
114
|
|
|
81
115
|
<center>
|
|
82
|
-
<b>Because</b> it does nothing
|
|
116
|
+
<b>Because</b> it does nothing special, <code>pi-simple-team</code> can construct any team graph you need.
|
|
83
117
|
</center>
|
|
84
118
|
<br>
|
|
85
119
|
That prompt gives you this graph:
|
|
@@ -124,7 +158,7 @@ when stuck. `"]
|
|
|
124
158
|
|
|
125
159
|
Tokens, intelligence and time are never wasted on busy-polling for messages.
|
|
126
160
|
|
|
127
|
-
Instead, `pi-simple-team` pushes messages to the
|
|
161
|
+
Instead, `pi-simple-team` pushes messages to the recipients.
|
|
128
162
|
|
|
129
163
|
This is both efficient and effective:
|
|
130
164
|
|
|
@@ -147,7 +181,7 @@ Teammates publish a one-liner:
|
|
|
147
181
|
|
|
148
182
|
> <span style="color:grey">reviewer </span> Reading implementation, will finalize review in a few minutes.
|
|
149
183
|
|
|
150
|
-
Your main agent calls `teamstatus` and understands exactly what
|
|
184
|
+
Your main agent calls `teamstatus` and understands exactly what is going on. Main does not ask teammates for updates or clutter their context.
|
|
151
185
|
|
|
152
186
|
### 🌡️ Context window self-awareness
|
|
153
187
|
|
|
@@ -199,6 +233,12 @@ A missing file that once held session history causes resume to fail. Persisted s
|
|
|
199
233
|
|
|
200
234
|
`team_add` creates new RPC teammates only for a running team owned by the current main session.
|
|
201
235
|
|
|
236
|
+
The `canOverseeOwnTeams` capability persists with the teammate attachment and returns after resume.
|
|
237
|
+
|
|
238
|
+
For an overseeing teammate, `teamsend` and `teamstatus` use the parent team when `team` is omitted. Set `team` to operate on one of its own teams. `report_context_window` reports itself when `targets` is omitted and inspects its own teammates when `targets` is set.
|
|
239
|
+
|
|
240
|
+
RPC shutdown waits while an overseeing teammate stops its own teams.
|
|
241
|
+
|
|
202
242
|
**One Pi session can have only one live runtime.** Pi does not lock session files against concurrent writers.
|
|
203
243
|
|
|
204
244
|
|
|
@@ -216,16 +256,18 @@ pi install npm:@giladbarnea/pi-simple-team
|
|
|
216
256
|
Kept minimal:
|
|
217
257
|
|
|
218
258
|
|
|
219
|
-
| Role
|
|
220
|
-
|
|
|
259
|
+
| Role | For | Tools |
|
|
260
|
+
| --- | --- | --- |
|
|
221
261
|
| **Main agent** | Team lifecycle | `team_spawn`, `team_list`, `team_resume`, `team_add`, `team_shutdown` |
|
|
222
|
-
|
|
|
223
|
-
|
|
|
224
|
-
|
|
|
225
|
-
| **
|
|
226
|
-
|
|
|
227
|
-
|
|
|
228
|
-
|
|
|
262
|
+
| | With team | `teamsend` |
|
|
263
|
+
| | On team | `teamstatus`, `teamlog` |
|
|
264
|
+
| | On everyone | `report_context_window` |
|
|
265
|
+
| **Overseeing teammate** | On own teams | Same tools as the main agent |
|
|
266
|
+
| | With parent team | `teamsend`, `teamstatus`, `teammain` |
|
|
267
|
+
| **Teammates** | With team | `teamsend` |
|
|
268
|
+
| | With main | `teammain` |
|
|
269
|
+
| | On self | `report_context_window` |
|
|
270
|
+
| **Everyone** | For everyone | `teamstatus` |
|
|
229
271
|
|
|
230
272
|
|
|
231
273
|
---
|
|
@@ -246,4 +288,5 @@ Kept minimal:
|
|
|
246
288
|
|
|
247
289
|
- [x] Resume all or selected teammates from a dormant team.
|
|
248
290
|
- [x] Add new teammates after a team has spawned.
|
|
291
|
+
- [x] Let opted-in teammates create and manage teams of their own.
|
|
249
292
|
- [ ] Main forces `/compact` on select teammate.
|
package/child-tools.ts
CHANGED
|
@@ -18,6 +18,7 @@ export interface ChildRuntimeConfig {
|
|
|
18
18
|
teammateName: string;
|
|
19
19
|
visible: boolean;
|
|
20
20
|
participants: string[];
|
|
21
|
+
canOverseeOwnTeams: boolean;
|
|
21
22
|
interruptWaitTimeoutMilliseconds?: number;
|
|
22
23
|
}
|
|
23
24
|
|
|
@@ -46,6 +47,7 @@ function readRequiredChildRuntimeConfig(): ChildRuntimeConfig {
|
|
|
46
47
|
teammateName: requiredEnvironmentVariable("PI_SIMPLE_TEAM_MEMBER"),
|
|
47
48
|
visible: process.env.PI_SIMPLE_TEAM_VISIBLE_CHILD === "1",
|
|
48
49
|
participants: readParticipants(),
|
|
50
|
+
canOverseeOwnTeams: process.env.PI_SIMPLE_TEAM_CAN_OVERSEE_OWN_TEAMS === "1",
|
|
49
51
|
};
|
|
50
52
|
}
|
|
51
53
|
|
|
@@ -54,7 +56,7 @@ export function readChildRuntimeConfig(): ChildRuntimeConfig | undefined {
|
|
|
54
56
|
return readRequiredChildRuntimeConfig();
|
|
55
57
|
}
|
|
56
58
|
|
|
57
|
-
async function callParent(config: ChildRuntimeConfig, tool: string, args: JsonRecord, signal?: AbortSignal): Promise<JsonRecord> {
|
|
59
|
+
export async function callParent(config: ChildRuntimeConfig, tool: string, args: JsonRecord, signal?: AbortSignal): Promise<JsonRecord> {
|
|
58
60
|
const response = await fetch(config.callbackUrl, {
|
|
59
61
|
method: "POST",
|
|
60
62
|
headers: { "content-type": "application/json" },
|
package/index.ts
CHANGED
|
@@ -11,7 +11,7 @@ import { bundledAiToAiSkillInstruction } from "./bundled-skill.ts";
|
|
|
11
11
|
import { formatContextWindowReport, requireKnownContextUsage, type KnownContextUsage } from "./context-window.ts";
|
|
12
12
|
import { formatScopedModelGuidance, validateTeammateModels, type ModelReference } from "./model-preflight.ts";
|
|
13
13
|
import { composeSystemPrompt } from "./system-prompt.ts";
|
|
14
|
-
import { readChildRuntimeConfig, registerChildTools } from "./child-tools.ts";
|
|
14
|
+
import { callParent, readChildRuntimeConfig, registerChildTools } from "./child-tools.ts";
|
|
15
15
|
import {
|
|
16
16
|
canonicalProjectDirectory,
|
|
17
17
|
claimTeamLease,
|
|
@@ -61,6 +61,7 @@ interface TeammateSpec {
|
|
|
61
61
|
model: string;
|
|
62
62
|
thinking?: ThinkingLevel;
|
|
63
63
|
inheritContext?: boolean;
|
|
64
|
+
canOverseeOwnTeams?: boolean;
|
|
64
65
|
}
|
|
65
66
|
|
|
66
67
|
type TeammateTransport = "rpc" | "herdr";
|
|
@@ -71,6 +72,7 @@ interface TeammateState {
|
|
|
71
72
|
model: string;
|
|
72
73
|
thinking: ThinkingLevel;
|
|
73
74
|
inheritContext: boolean;
|
|
75
|
+
canOverseeOwnTeams: boolean;
|
|
74
76
|
transport: TeammateTransport;
|
|
75
77
|
sessionId?: string;
|
|
76
78
|
sessionFile?: string;
|
|
@@ -111,6 +113,7 @@ const teamLiteExtensionPath = fileURLToPath(import.meta.url);
|
|
|
111
113
|
const thinkingLevels = ["low", "medium", "high", "xhigh", "max"] as const;
|
|
112
114
|
const defaultThinkingLevel: ThinkingLevel = "xhigh";
|
|
113
115
|
const visibleDeliveryTimeoutMilliseconds = 30_000;
|
|
116
|
+
const defaultRpcShutdownGraceMilliseconds = 1_000;
|
|
114
117
|
const teamMessageType = "pi-simple-team";
|
|
115
118
|
const teams = new Map<string, TeamState>();
|
|
116
119
|
const callbackToken = crypto.randomBytes(24).toString("hex");
|
|
@@ -528,6 +531,7 @@ function createTeammateState(team: TeamState, teammateSpec: TeammateSpec): Teamm
|
|
|
528
531
|
model: teammateSpec.model,
|
|
529
532
|
thinking,
|
|
530
533
|
inheritContext: Boolean(teammateSpec.inheritContext),
|
|
534
|
+
canOverseeOwnTeams: Boolean(teammateSpec.canOverseeOwnTeams),
|
|
531
535
|
transport: team.showOnHerdrPanes ? "herdr" : "rpc",
|
|
532
536
|
sessionMaterialized: false,
|
|
533
537
|
visibleReady,
|
|
@@ -552,6 +556,7 @@ function childEnvironmentOverrides(team: TeamState, teammate: TeammateState, par
|
|
|
552
556
|
PI_SIMPLE_TEAM_TEAM_NAME: team.name,
|
|
553
557
|
PI_SIMPLE_TEAM_MEMBER: teammate.name,
|
|
554
558
|
PI_SIMPLE_TEAM_PARTICIPANTS: JSON.stringify(participants),
|
|
559
|
+
PI_SIMPLE_TEAM_CAN_OVERSEE_OWN_TEAMS: teammate.canOverseeOwnTeams ? "1" : "0",
|
|
555
560
|
};
|
|
556
561
|
}
|
|
557
562
|
|
|
@@ -589,7 +594,7 @@ function attachRpcTeammate(team: TeamState, teammate: TeammateState, participant
|
|
|
589
594
|
"--no-themes",
|
|
590
595
|
...modelArgs,
|
|
591
596
|
"--system-prompt",
|
|
592
|
-
composeSystemPrompt(team.name, team.teamPrompt, teammate.name, teammate.prompt, participants),
|
|
597
|
+
composeSystemPrompt(team.name, team.teamPrompt, teammate.name, teammate.prompt, participants, teammate.canOverseeOwnTeams),
|
|
593
598
|
];
|
|
594
599
|
const proc = childProcess.spawn("pi", args, {
|
|
595
600
|
cwd: team.projectDirectory ?? process.cwd(),
|
|
@@ -649,7 +654,7 @@ async function attachVisibleTeammate(
|
|
|
649
654
|
herdrTabId: string,
|
|
650
655
|
options: RpcStartOptions,
|
|
651
656
|
): Promise<void> {
|
|
652
|
-
const systemPrompt = composeSystemPrompt(team.name, team.teamPrompt, teammate.name, teammate.prompt, participants);
|
|
657
|
+
const systemPrompt = composeSystemPrompt(team.name, team.teamPrompt, teammate.name, teammate.prompt, participants, teammate.canOverseeOwnTeams);
|
|
653
658
|
const environment = childEnvironmentOverrides(team, teammate, participants, true);
|
|
654
659
|
const sessionArgs = options.sessionFile
|
|
655
660
|
? ["--session", options.sessionFile]
|
|
@@ -718,6 +723,7 @@ function manifestMemberFromTeammate(teammate: TeammateState): TeamManifestMember
|
|
|
718
723
|
model: teammate.model,
|
|
719
724
|
thinking: teammate.thinking,
|
|
720
725
|
inheritContext: teammate.inheritContext,
|
|
726
|
+
canOverseeOwnTeams: teammate.canOverseeOwnTeams,
|
|
721
727
|
transport: teammate.transport,
|
|
722
728
|
live: teammate.alive,
|
|
723
729
|
sessionId: teammate.sessionId,
|
|
@@ -766,8 +772,10 @@ async function stopRpcTeammate(teammate: TeammateState): Promise<void> {
|
|
|
766
772
|
};
|
|
767
773
|
processToStop.once("exit", resolveExit);
|
|
768
774
|
processToStop.kill("SIGTERM");
|
|
769
|
-
|
|
770
|
-
|
|
775
|
+
if (!teammate.canOverseeOwnTeams) {
|
|
776
|
+
forceKillTimeout = setTimeout(() => processToStop.kill("SIGKILL"), defaultRpcShutdownGraceMilliseconds);
|
|
777
|
+
forceKillTimeout.unref();
|
|
778
|
+
}
|
|
771
779
|
});
|
|
772
780
|
teammate.process = undefined;
|
|
773
781
|
}
|
|
@@ -997,6 +1005,7 @@ function teammateSchema(modelGuidance: string) {
|
|
|
997
1005
|
model: Type.String({ description: `Canonical provider/model id for this teammate. ${modelGuidance}` }),
|
|
998
1006
|
thinking: Type.Optional(StringEnum(thinkingLevels, { description: "Thinking level for this teammate. Defaults to xhigh.", default: defaultThinkingLevel })),
|
|
999
1007
|
inheritContext: Type.Optional(Type.Boolean({ description: "Start from a fork of main's persisted session. The fork is taken during asynchronous child startup. Defaults to false.", default: false })),
|
|
1008
|
+
canOverseeOwnTeams: Type.Optional(Type.Boolean({ description: "Allow this teammate to create and manage teams of its own. Defaults to false.", default: false })),
|
|
1000
1009
|
});
|
|
1001
1010
|
}
|
|
1002
1011
|
|
|
@@ -1024,6 +1033,7 @@ function restoreTeamState(owner: symbol, ownerPi: ExtensionAPI, manifest: TeamMa
|
|
|
1024
1033
|
model: member.model,
|
|
1025
1034
|
thinking: member.thinking as ThinkingLevel,
|
|
1026
1035
|
inheritContext: member.inheritContext,
|
|
1036
|
+
canOverseeOwnTeams: Boolean(member.canOverseeOwnTeams),
|
|
1027
1037
|
});
|
|
1028
1038
|
teammate.transport = "rpc";
|
|
1029
1039
|
teammate.sessionId = member.sessionId;
|
|
@@ -1058,11 +1068,11 @@ export default function (pi: ExtensionAPI) {
|
|
|
1058
1068
|
const childRuntimeConfig = readChildRuntimeConfig();
|
|
1059
1069
|
if (childRuntimeConfig) {
|
|
1060
1070
|
registerChildTools(pi, childRuntimeConfig);
|
|
1061
|
-
return;
|
|
1071
|
+
if (!childRuntimeConfig.canOverseeOwnTeams) return;
|
|
1062
1072
|
}
|
|
1063
1073
|
|
|
1064
1074
|
const owner = Symbol("pi-simple-team-owner");
|
|
1065
|
-
const sessionTeammateRoster
|
|
1075
|
+
const sessionTeammateRoster = childRuntimeConfig?.participants ?? [];
|
|
1066
1076
|
pi.registerMessageRenderer(teamMessageType, (message, _options, theme) => renderTeamMessage(message, theme, getMarkdownTheme(), sessionTeammateRoster));
|
|
1067
1077
|
|
|
1068
1078
|
pi.registerCommand("team", {
|
|
@@ -1202,13 +1212,19 @@ export default function (pi: ExtensionAPI) {
|
|
|
1202
1212
|
defineTool({
|
|
1203
1213
|
name: "team_list",
|
|
1204
1214
|
label: "Team List",
|
|
1205
|
-
description:
|
|
1215
|
+
description: childRuntimeConfig
|
|
1216
|
+
? "List active and dormant teams created by this overseeing teammate."
|
|
1217
|
+
: "List active and dormant teams for the current project.",
|
|
1206
1218
|
promptSnippet: "List teams for the current project",
|
|
1207
1219
|
parameters: Type.Object({}),
|
|
1208
1220
|
async execute(_toolCallId, _params, _signal, _onUpdate, context) {
|
|
1209
1221
|
const projectDirectory = context.sessionManager?.getCwd?.() ?? context.cwd;
|
|
1210
1222
|
if (!projectDirectory) throw new Error("team_list requires a project directory");
|
|
1211
|
-
const
|
|
1223
|
+
const managerSessionId = childRuntimeConfig ? context.sessionManager?.getSessionId?.() : undefined;
|
|
1224
|
+
if (childRuntimeConfig && !managerSessionId) throw new Error("team_list requires a persistent overseeing teammate session");
|
|
1225
|
+
const manifests = listTeamManifests(projectDirectory).filter(
|
|
1226
|
+
(manifest) => !managerSessionId || manifest.originMainSessionId === managerSessionId,
|
|
1227
|
+
);
|
|
1212
1228
|
return toolResult({
|
|
1213
1229
|
teams: manifests.map((manifest) => {
|
|
1214
1230
|
const liveTeam = teams.get(manifest.id);
|
|
@@ -1221,6 +1237,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
1221
1237
|
members: manifest.members.map((member) => ({
|
|
1222
1238
|
name: member.name,
|
|
1223
1239
|
live: liveTeam?.members.get(member.name)?.alive ?? member.live,
|
|
1240
|
+
canOverseeOwnTeams: Boolean(member.canOverseeOwnTeams),
|
|
1224
1241
|
sessionId: member.sessionId,
|
|
1225
1242
|
sessionFile: member.sessionFile,
|
|
1226
1243
|
})),
|
|
@@ -1239,7 +1256,9 @@ export default function (pi: ExtensionAPI) {
|
|
|
1239
1256
|
defineTool({
|
|
1240
1257
|
name: "team_resume",
|
|
1241
1258
|
label: "Team Resume",
|
|
1242
|
-
description:
|
|
1259
|
+
description: childRuntimeConfig
|
|
1260
|
+
? "Resume all or selected stopped members of a dormant team created by this overseeing teammate."
|
|
1261
|
+
: "Resume all stopped teammates in a dormant current-project team, or only selected stopped teammates.",
|
|
1243
1262
|
promptSnippet: "Resume all or selected stopped teammates",
|
|
1244
1263
|
parameters: Type.Object({
|
|
1245
1264
|
team: Type.String({ description: "Persistent team ID" }),
|
|
@@ -1249,7 +1268,11 @@ export default function (pi: ExtensionAPI) {
|
|
|
1249
1268
|
async execute(_toolCallId, params, _signal, _onUpdate, context) {
|
|
1250
1269
|
const rawProjectDirectory = context.sessionManager?.getCwd?.() ?? context.cwd;
|
|
1251
1270
|
if (!rawProjectDirectory) throw new Error("team_resume requires a project directory");
|
|
1252
|
-
const
|
|
1271
|
+
const managerSessionId = childRuntimeConfig ? context.sessionManager?.getSessionId?.() : undefined;
|
|
1272
|
+
if (childRuntimeConfig && !managerSessionId) throw new Error("team_resume requires a persistent overseeing teammate session");
|
|
1273
|
+
const manifest = listTeamManifests(rawProjectDirectory).find(
|
|
1274
|
+
(candidate) => candidate.id === params.team && (!managerSessionId || candidate.originMainSessionId === managerSessionId),
|
|
1275
|
+
);
|
|
1253
1276
|
if (!manifest) throw new Error(`Unknown current-project team: ${params.team}`);
|
|
1254
1277
|
const requestedNames = params.teammates?.map(compactName) ?? manifest.members.map((member) => member.name);
|
|
1255
1278
|
const duplicateNames = requestedNames.filter((name, index) => requestedNames.indexOf(name) !== index);
|
|
@@ -1408,18 +1431,27 @@ export default function (pi: ExtensionAPI) {
|
|
|
1408
1431
|
defineTool({
|
|
1409
1432
|
name: "teamsend",
|
|
1410
1433
|
label: "Team Send",
|
|
1411
|
-
description:
|
|
1434
|
+
description: childRuntimeConfig
|
|
1435
|
+
? "Send to parent-team peers when team is omitted, or to teammates in an owned team when team is set. Fire-and-forget; does not wait for replies."
|
|
1436
|
+
: "Send a message from main to teammate(s). Fire-and-forget; does not wait for replies. Teammates will send you messages as they deem appropriate by way of push.",
|
|
1412
1437
|
promptSnippet: "Send a message from main to teammate(s)",
|
|
1413
1438
|
renderShell: "self",
|
|
1414
1439
|
renderCall: (args, theme, context) => renderTeamToolCall("teamsend", args, theme, context, sessionTeammateRoster),
|
|
1415
1440
|
renderResult: (result, options, theme, context) => renderTeamToolResult("teamsend", result, options, theme, context, getMarkdownTheme(), sessionTeammateRoster),
|
|
1416
1441
|
parameters: Type.Object({
|
|
1417
|
-
team: Type.Optional(Type.String({ description: "Team name; optional only when exactly one team exists" })),
|
|
1442
|
+
team: Type.Optional(Type.String({ description: childRuntimeConfig ? "Owned team name. Omit to use the parent team." : "Team name; optional only when exactly one team exists" })),
|
|
1418
1443
|
to: Type.Array(Type.String(), { description: "Recipient teammate names" }),
|
|
1419
1444
|
message: Type.String({ description: "Message to send" }),
|
|
1420
1445
|
interrupt: Type.Optional(Type.Boolean({ description: "Abort busy recipients before delivery" })),
|
|
1421
1446
|
}),
|
|
1422
|
-
async execute(_toolCallId, params) {
|
|
1447
|
+
async execute(_toolCallId, params, signal) {
|
|
1448
|
+
if (childRuntimeConfig && !params.team) {
|
|
1449
|
+
return toolResult(await callParent(childRuntimeConfig, "teamsend", {
|
|
1450
|
+
to: params.to,
|
|
1451
|
+
message: params.message,
|
|
1452
|
+
...(params.interrupt === undefined ? {} : { interrupt: params.interrupt }),
|
|
1453
|
+
}, signal));
|
|
1454
|
+
}
|
|
1423
1455
|
const team = resolveTeam(owner, params.team);
|
|
1424
1456
|
const recipients = resolveRecipients(team, params.to);
|
|
1425
1457
|
const interrupt = Boolean(params.interrupt);
|
|
@@ -1433,18 +1465,26 @@ export default function (pi: ExtensionAPI) {
|
|
|
1433
1465
|
defineTool({
|
|
1434
1466
|
name: "teamstatus",
|
|
1435
1467
|
label: "Team Status",
|
|
1436
|
-
description:
|
|
1468
|
+
description: childRuntimeConfig
|
|
1469
|
+
? "Set or read parent-team status when team is omitted. Set or read an owned team's status when team is set."
|
|
1470
|
+
: "Set main's status for a team and/or read team statuses.",
|
|
1437
1471
|
promptSnippet: "Set/read team status maps",
|
|
1438
1472
|
renderShell: "self",
|
|
1439
1473
|
renderCall: (args, theme, context) => renderTeamToolCall("teamstatus", args, theme, context, sessionTeammateRoster),
|
|
1440
1474
|
renderResult: (result, options, theme, context) => renderTeamToolResult("teamstatus", result, options, theme, context, undefined, sessionTeammateRoster),
|
|
1441
1475
|
parameters: Type.Object({
|
|
1442
|
-
team: Type.Optional(Type.String({ description: "Team name; optional for listing all statuses or when exactly one team exists" })),
|
|
1476
|
+
team: Type.Optional(Type.String({ description: childRuntimeConfig ? "Owned team name. Omit to use the parent team." : "Team name; optional for listing all statuses or when exactly one team exists" })),
|
|
1443
1477
|
// TODO: make gerund and phrase optionality a XOR.
|
|
1444
1478
|
gerund: Type.Optional(Type.String({ description: "Set one-word gerund main status" })),
|
|
1445
1479
|
phrase: Type.Optional(Type.String({ description: "Short main status verb-oriented phrase." })),
|
|
1446
1480
|
}),
|
|
1447
|
-
async execute(_toolCallId, params) {
|
|
1481
|
+
async execute(_toolCallId, params, signal) {
|
|
1482
|
+
if (childRuntimeConfig && !params.team) {
|
|
1483
|
+
return toolResult(await callParent(childRuntimeConfig, "teamstatus", {
|
|
1484
|
+
...(params.gerund === undefined ? {} : { gerund: params.gerund }),
|
|
1485
|
+
...(params.phrase === undefined ? {} : { phrase: params.phrase }),
|
|
1486
|
+
}, signal));
|
|
1487
|
+
}
|
|
1448
1488
|
if (!params.team && params.gerund === undefined && params.phrase === undefined) {
|
|
1449
1489
|
return toolResult({ teams: allStatuses(owner) });
|
|
1450
1490
|
}
|
|
@@ -1460,12 +1500,20 @@ export default function (pi: ExtensionAPI) {
|
|
|
1460
1500
|
defineTool({
|
|
1461
1501
|
name: "report_context_window",
|
|
1462
1502
|
label: "Report Context Window",
|
|
1463
|
-
description:
|
|
1503
|
+
description: childRuntimeConfig
|
|
1504
|
+
? "Report your own context-window use when targets is omitted. When targets is present, report selected teammates in owned teams and yourself last."
|
|
1505
|
+
: "Report context-window use for selected teammates and main. Main's report is always last.",
|
|
1464
1506
|
promptSnippet: "Report context-window use for selected teammates and main",
|
|
1465
1507
|
parameters: Type.Object({
|
|
1466
|
-
targets:
|
|
1508
|
+
targets: childRuntimeConfig
|
|
1509
|
+
? Type.Optional(Type.Array(Type.String({ minLength: 1 }), { description: "Owned-team teammate names. Omit to report only yourself." }))
|
|
1510
|
+
: Type.Array(Type.String({ minLength: 1 }), { description: "Teammate names. Use an empty list to report only main." }),
|
|
1467
1511
|
}),
|
|
1468
1512
|
async execute(_toolCallId, params, signal, _onUpdate, context) {
|
|
1513
|
+
if (params.targets === undefined) {
|
|
1514
|
+
const text = formatContextWindowReport("You have", requireKnownContextUsage(context.getContextUsage()));
|
|
1515
|
+
return { content: [{ type: "text" as const, text }], details: {} };
|
|
1516
|
+
}
|
|
1469
1517
|
const teammates = resolveContextTargets(owner, params.targets);
|
|
1470
1518
|
const reports = await Promise.all(
|
|
1471
1519
|
teammates.map(async (teammate) => formatContextWindowReport(`Teammate ${teammate.name} has`, await getTeammateContextUsage(teammate, signal))),
|
package/package.json
CHANGED
package/system-prompt.ts
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import { bundledAiToAiSkillInstruction } from "./bundled-skill.ts";
|
|
2
2
|
|
|
3
|
-
export function composeSystemPrompt(
|
|
3
|
+
export function composeSystemPrompt(
|
|
4
|
+
teamName: string,
|
|
5
|
+
teamPrompt: string,
|
|
6
|
+
teammateName: string,
|
|
7
|
+
teammatePrompt: string,
|
|
8
|
+
participants: string[],
|
|
9
|
+
canOverseeOwnTeams = false,
|
|
10
|
+
): string {
|
|
4
11
|
return [
|
|
5
12
|
bundledAiToAiSkillInstruction,
|
|
6
13
|
teamPrompt.trim(),
|
|
@@ -10,6 +17,10 @@ export function composeSystemPrompt(teamName: string, teamPrompt: string, teamma
|
|
|
10
17
|
"Use teamsend to talk to teammates, teammain to talk to the main agent, and teamstatus to set/read public statuses.",
|
|
11
18
|
"From the sender’s point of view, teamsend is fire-and-forget. From the recipient’s point of view, the message is pushed to context as soon as possible.",
|
|
12
19
|
"The main agent is the current coordinator. Use the team tools and available session history to share relevant context.",
|
|
20
|
+
canOverseeOwnTeams && "You can create and manage teams of your own with team_spawn, team_list, team_resume, team_add, teamsend, teamstatus, report_context_window, teamlog, and team_shutdown.",
|
|
21
|
+
canOverseeOwnTeams && "Your manager tools are scoped to teams created by this Pi session. They cannot manage this parent team or teams owned by other sessions.",
|
|
22
|
+
canOverseeOwnTeams && "For teamsend and teamstatus, omit `team` to operate on this parent team. Set `team` to operate on a team you own.",
|
|
23
|
+
canOverseeOwnTeams && "For report_context_window, omit `targets` to report yourself. Set `targets` to inspect teammates in teams you own.",
|
|
13
24
|
"As soon as you wake up, call teamstatus to acknowledge that you received your instructions before doing substantive work.",
|
|
14
25
|
"Whenever you receive a message from main or a teammate, call teamstatus first to acknowledge that specific message, then proceed.",
|
|
15
26
|
"Never set a waiting status until after you have sent the teammate you are waiting for a teamsend describing exactly what you need from them.",
|
package/team-registry.ts
CHANGED
|
@@ -10,6 +10,7 @@ export interface TeamManifestMember {
|
|
|
10
10
|
model: string;
|
|
11
11
|
thinking: string;
|
|
12
12
|
inheritContext: boolean;
|
|
13
|
+
canOverseeOwnTeams?: boolean;
|
|
13
14
|
transport: "rpc" | "herdr";
|
|
14
15
|
live: boolean;
|
|
15
16
|
sessionId: string;
|
|
@@ -78,6 +79,7 @@ function isManifestMember(value: unknown): value is TeamManifestMember {
|
|
|
78
79
|
typeof member.model === "string" &&
|
|
79
80
|
typeof member.thinking === "string" &&
|
|
80
81
|
typeof member.inheritContext === "boolean" &&
|
|
82
|
+
(member.canOverseeOwnTeams === undefined || typeof member.canOverseeOwnTeams === "boolean") &&
|
|
81
83
|
(member.transport === "rpc" || member.transport === "herdr") &&
|
|
82
84
|
typeof member.live === "boolean" &&
|
|
83
85
|
typeof member.sessionId === "string" &&
|