@giladbarnea/pi-simple-team 1.0.45 → 2.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/README.md +24 -12
- package/child-tools.ts +24 -22
- package/index.ts +388 -302
- package/model-preflight.ts +1 -1
- package/package.json +1 -1
- package/render.ts +62 -58
- package/system-prompt.ts +11 -12
- package/team-registry.ts +13 -26
- package/team-selection.ts +57 -0
- package/team-ui.ts +2 -2
- package/teamlog.ts +26 -8
- package/teammate.ts +18 -0
package/README.md
CHANGED
|
@@ -119,7 +119,7 @@ Teammates publish a one-liner:
|
|
|
119
119
|
|
|
120
120
|
> <span style="color:grey">reviewer </span> Reading implementation, will finalize review in a few minutes.
|
|
121
121
|
|
|
122
|
-
Your main agent calls `
|
|
122
|
+
Your main agent calls `team_status` and understands exactly what is going on. Main does not ask teammates for updates or clutter their context.
|
|
123
123
|
|
|
124
124
|
### 🌡️ Context window self-awareness
|
|
125
125
|
|
|
@@ -143,7 +143,7 @@ You can stop babysitting context windows.
|
|
|
143
143
|
|
|
144
144
|
### 📡 Live, zero-cost observability
|
|
145
145
|
|
|
146
|
-
Your main uses `
|
|
146
|
+
Your main uses `team_log` when it needs to understand the chain of events in high granularity.
|
|
147
147
|
|
|
148
148
|
Provides main a timestamped, filterable, append-only record of the team’s messages, tool calls, and lifecycle events.
|
|
149
149
|
|
|
@@ -208,17 +208,29 @@ Kept minimal:
|
|
|
208
208
|
|
|
209
209
|
| Role | For | Tools |
|
|
210
210
|
| --- | --- | --- |
|
|
211
|
-
| **Main agent** | Team lifecycle | `team_spawn`, `team_list`, `team_resume`, `
|
|
212
|
-
| | With team | `
|
|
213
|
-
| | On team | `
|
|
214
|
-
| | On everyone | `
|
|
211
|
+
| **Main agent** | Team lifecycle | `team_spawn`, `team_list`, `team_resume`, `team_add_teammates`, `team_shutdown` |
|
|
212
|
+
| | With team | `team_send_message` |
|
|
213
|
+
| | On team | `team_status`, `team_log` |
|
|
214
|
+
| | On everyone | `get_context_window_usage` |
|
|
215
215
|
| | On self | `schedule_reminder` |
|
|
216
|
-
| **
|
|
217
|
-
| | With parent team | `
|
|
218
|
-
| **Teammates** | With team | `
|
|
219
|
-
| | With main | `
|
|
220
|
-
| | On self | `
|
|
221
|
-
| **Everyone** | For everyone | `
|
|
216
|
+
| **Managing teammate** | On self and own teams | Same tools as the main agent |
|
|
217
|
+
| | With parent team | `team_send_message`, `team_status`, `send_main_message` |
|
|
218
|
+
| **Teammates** | With team | `team_send_message` |
|
|
219
|
+
| | With main | `send_main_message` |
|
|
220
|
+
| | On self | `get_context_window_usage` |
|
|
221
|
+
| **Everyone** | For everyone | `team_status` |
|
|
222
|
+
|
|
223
|
+
`team_spawn`, `team_resume`, and `team_add_teammates` start work automatically once every affected teammate is ready. Set `startIdle: true` to leave those teammates idle instead.
|
|
224
|
+
|
|
225
|
+
On resume, `resumptionPrompt` adds instructions to the conversation without changing saved system prompts. With `startIdle: true`, those instructions wait in context for the next turn.
|
|
226
|
+
|
|
227
|
+
Existing teammates can be selected by name or Pi session ID in the same input field. Messages, logs, and context usage share a `targets` list. Select a team for all its teammates, or select individual teammates across your teams. Ambiguous names return IDs you can use instead.
|
|
228
|
+
|
|
229
|
+
Spawn, resume, and add return the complete roster. Results distinguish a live runtime from active work, including work that was already underway before the call.
|
|
230
|
+
|
|
231
|
+
Set `showOnHerdrPane: true` on individual teammates to open their panes. An explicit `showOnHerdrPanes` value on spawn overrides all individual settings.
|
|
232
|
+
|
|
233
|
+
Message tools return `published: true` when the extension accepts a message for delivery. If delivery later fails, the sender receives the error automatically.
|
|
222
234
|
|
|
223
235
|
|
|
224
236
|
---
|
package/child-tools.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { defineTool, getMarkdownTheme, type ExtensionAPI, type ExtensionContext
|
|
|
3
3
|
import { Type } from "typebox";
|
|
4
4
|
import { formatContextWindowReport, requireKnownContextUsage } from "./context-window.ts";
|
|
5
5
|
import { renderTeamMessage } from "./render.ts";
|
|
6
|
+
import { targetDescription, interruptDescription } from "./team-selection.ts";
|
|
6
7
|
|
|
7
8
|
type JsonRecord = Record<string, unknown>;
|
|
8
9
|
|
|
@@ -17,7 +18,7 @@ export interface ChildRuntimeConfig {
|
|
|
17
18
|
teamName: string;
|
|
18
19
|
teammateName: string;
|
|
19
20
|
participants: string[];
|
|
20
|
-
|
|
21
|
+
canManageOwnTeams: boolean;
|
|
21
22
|
interruptWaitTimeoutMilliseconds?: number;
|
|
22
23
|
}
|
|
23
24
|
|
|
@@ -42,10 +43,10 @@ function readRequiredChildRuntimeConfig(): ChildRuntimeConfig {
|
|
|
42
43
|
callbackUrl: requiredEnvironmentVariable("PI_SIMPLE_TEAM_CALLBACK_URL"),
|
|
43
44
|
callbackToken: requiredEnvironmentVariable("PI_SIMPLE_TEAM_CALLBACK_TOKEN"),
|
|
44
45
|
teamId,
|
|
45
|
-
teamName:
|
|
46
|
+
teamName: requiredEnvironmentVariable("PI_SIMPLE_TEAM_TEAM_NAME"),
|
|
46
47
|
teammateName: requiredEnvironmentVariable("PI_SIMPLE_TEAM_MEMBER"),
|
|
47
48
|
participants: readParticipants(),
|
|
48
|
-
|
|
49
|
+
canManageOwnTeams: process.env.PI_SIMPLE_TEAM_CAN_MANAGE_OWN_TEAMS === "1",
|
|
49
50
|
};
|
|
50
51
|
}
|
|
51
52
|
|
|
@@ -105,6 +106,7 @@ interface ChildDelivery {
|
|
|
105
106
|
message: string;
|
|
106
107
|
formattedMessage: string;
|
|
107
108
|
interrupt: boolean;
|
|
109
|
+
triggerTurn?: boolean;
|
|
108
110
|
}
|
|
109
111
|
|
|
110
112
|
/** The one live runtime every child gets: a delivery server, parent registration, and lifecycle callbacks. */
|
|
@@ -183,7 +185,7 @@ function startChildRuntime(pi: ExtensionAPI, config: ChildRuntimeConfig): void {
|
|
|
183
185
|
return;
|
|
184
186
|
}
|
|
185
187
|
|
|
186
|
-
if (body.tool === "
|
|
188
|
+
if (body.tool === "get_context_window_usage") {
|
|
187
189
|
writeJson(response, 200, { contextUsage: requireKnownContextUsage(context.getContextUsage()) });
|
|
188
190
|
return;
|
|
189
191
|
}
|
|
@@ -199,6 +201,7 @@ function startChildRuntime(pi: ExtensionAPI, config: ChildRuntimeConfig): void {
|
|
|
199
201
|
activeContext.abort();
|
|
200
202
|
await waitForIdle();
|
|
201
203
|
}
|
|
204
|
+
if (delivery.triggerTurn !== false) await notifyParent({ type: "work_queued" });
|
|
202
205
|
|
|
203
206
|
pi.sendMessage(
|
|
204
207
|
{
|
|
@@ -213,7 +216,7 @@ function startChildRuntime(pi: ExtensionAPI, config: ChildRuntimeConfig): void {
|
|
|
213
216
|
message: delivery.message,
|
|
214
217
|
},
|
|
215
218
|
},
|
|
216
|
-
{ deliverAs: "steer", triggerTurn:
|
|
219
|
+
{ deliverAs: "steer", triggerTurn: delivery.triggerTurn !== false },
|
|
217
220
|
);
|
|
218
221
|
writeJson(response, 200, { accepted: true, team: config.teamName, from: delivery.from, to: delivery.to, interrupt: delivery.interrupt });
|
|
219
222
|
} catch (error) {
|
|
@@ -279,10 +282,10 @@ export function registerChildTools(pi: ExtensionAPI, config: ChildRuntimeConfig)
|
|
|
279
282
|
|
|
280
283
|
pi.registerTool(
|
|
281
284
|
defineTool({
|
|
282
|
-
name: "
|
|
283
|
-
label: "
|
|
284
|
-
description: "
|
|
285
|
-
parameters: Type.Object({}),
|
|
285
|
+
name: "get_context_window_usage",
|
|
286
|
+
label: "Context Window Usage",
|
|
287
|
+
description: "Get your current context-window use.",
|
|
288
|
+
parameters: Type.Object({}, { additionalProperties: false }),
|
|
286
289
|
async execute(_toolCallId, _params, _signal, _onUpdate, context) {
|
|
287
290
|
const text = formatContextWindowReport("You have", requireKnownContextUsage(context.getContextUsage()));
|
|
288
291
|
return { content: [{ type: "text" as const, text }], details: {} };
|
|
@@ -292,47 +295,46 @@ export function registerChildTools(pi: ExtensionAPI, config: ChildRuntimeConfig)
|
|
|
292
295
|
|
|
293
296
|
pi.registerTool(
|
|
294
297
|
defineTool({
|
|
295
|
-
name: "
|
|
298
|
+
name: "team_send_message",
|
|
296
299
|
label: "Team Send",
|
|
297
|
-
description: "
|
|
300
|
+
description: "Message teammates in your team. Use send_main_message to message main.",
|
|
298
301
|
parameters: Type.Object({
|
|
299
|
-
|
|
302
|
+
targets: Type.Array(Type.String({ minLength: 1 }), { minItems: 1, description: targetDescription }),
|
|
300
303
|
message: Type.String({ description: "Message to send" }),
|
|
301
|
-
interrupt: Type.Optional(Type.Boolean({
|
|
302
|
-
}),
|
|
304
|
+
interrupt: Type.Optional(Type.Union([Type.Boolean(), Type.Array(Type.String({ minLength: 1 }))], { description: interruptDescription })),
|
|
305
|
+
}, { additionalProperties: false }),
|
|
303
306
|
async execute(_toolCallId, params, signal) {
|
|
304
|
-
return toolResult(await callParent(config, "
|
|
307
|
+
return toolResult(await callParent(config, "team_send_message", params, signal));
|
|
305
308
|
},
|
|
306
309
|
}),
|
|
307
310
|
);
|
|
308
311
|
|
|
309
|
-
// TODO: should be renamed `sendmain` across the project.
|
|
310
312
|
pi.registerTool(
|
|
311
313
|
defineTool({
|
|
312
|
-
name: "
|
|
314
|
+
name: "send_main_message",
|
|
313
315
|
label: "Team Main",
|
|
314
316
|
description: "Send a message to the main agent.",
|
|
315
317
|
parameters: Type.Object({
|
|
316
318
|
message: Type.String({ description: "Message to send to the main agent" }),
|
|
317
|
-
}),
|
|
319
|
+
}, { additionalProperties: false }),
|
|
318
320
|
async execute(_toolCallId, params, signal) {
|
|
319
|
-
return toolResult(await callParent(config, "
|
|
321
|
+
return toolResult(await callParent(config, "send_main_message", params, signal));
|
|
320
322
|
},
|
|
321
323
|
}),
|
|
322
324
|
);
|
|
323
325
|
|
|
324
326
|
pi.registerTool(
|
|
325
327
|
defineTool({
|
|
326
|
-
name: "
|
|
328
|
+
name: "team_status",
|
|
327
329
|
label: "Team Status",
|
|
328
330
|
description: "Set your public status and read everyone's public status.",
|
|
329
331
|
// TODO: If this typing system supports it, I want gerund and phrase optionality to be a XOR
|
|
330
332
|
parameters: Type.Object({
|
|
331
333
|
gerund: Type.Optional(Type.String({ description: "One-word gerund status." })),
|
|
332
334
|
phrase: Type.Optional(Type.String({ description: "Short status phrase. Verb-oriented." })),
|
|
333
|
-
}),
|
|
335
|
+
}, { additionalProperties: false }),
|
|
334
336
|
async execute(_toolCallId, params, signal) {
|
|
335
|
-
return toolResult(await callParent(config, "
|
|
337
|
+
return toolResult(await callParent(config, "team_status", params, signal));
|
|
336
338
|
},
|
|
337
339
|
}),
|
|
338
340
|
);
|