@giladbarnea/pi-simple-team 2.0.7 → 2.0.9
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/child-tools.ts +18 -1
- package/package.json +1 -1
package/child-tools.ts
CHANGED
|
@@ -13,6 +13,19 @@ const teamMessageType = "pi-simple-team";
|
|
|
13
13
|
const defaultInterruptWaitTimeoutMilliseconds = 25_000;
|
|
14
14
|
const lifecycleCallbackRetryAttempts = 3;
|
|
15
15
|
|
|
16
|
+
/** Every tool a teammate registers in registerChildTools. */
|
|
17
|
+
export const childToolNames = ["get_context_window_usage", "team_send_message", "send_main_message", "team_status"] as const;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Pi 1.3 restores the tool loadout recorded in a resumed or forked transcript, and again after /tree. A teammate
|
|
21
|
+
* forked from main inherits main's loadout, which never declared teammate-only tools such as send_main_message.
|
|
22
|
+
*/
|
|
23
|
+
function activateChildTools(pi: ExtensionAPI): void {
|
|
24
|
+
const activeTools = pi.getActiveTools();
|
|
25
|
+
const missingTools = childToolNames.filter((name) => !activeTools.includes(name));
|
|
26
|
+
if (missingTools.length > 0) pi.setActiveTools([...activeTools, ...missingTools]);
|
|
27
|
+
}
|
|
28
|
+
|
|
16
29
|
export interface ChildRuntimeConfig {
|
|
17
30
|
callbackUrl: string;
|
|
18
31
|
callbackToken: string;
|
|
@@ -185,7 +198,10 @@ function startChildRuntime(pi: ExtensionAPI, config: ChildRuntimeConfig): void {
|
|
|
185
198
|
pi.on("session_compact", (_event, context) => { void reportRuntimeFacts(context); });
|
|
186
199
|
pi.on("model_select", (_event, context) => { void reportRuntimeFacts(context); });
|
|
187
200
|
pi.on("thinking_level_select", (_event, context) => { void reportRuntimeFacts(context); });
|
|
188
|
-
pi.on("session_tree", (_event, context) => {
|
|
201
|
+
pi.on("session_tree", (_event, context) => {
|
|
202
|
+
activateChildTools(pi);
|
|
203
|
+
void reportRuntimeFacts(context);
|
|
204
|
+
});
|
|
189
205
|
pi.on("tool_execution_start", (event) => {
|
|
190
206
|
notifyParent({ type: "tool_execution_start", toolCallId: event.toolCallId, toolName: event.toolName, args: event.args });
|
|
191
207
|
});
|
|
@@ -193,6 +209,7 @@ function startChildRuntime(pi: ExtensionAPI, config: ChildRuntimeConfig): void {
|
|
|
193
209
|
notifyParent({ type: "tool_execution_end", toolCallId: event.toolCallId, toolName: event.toolName, isError: event.isError, result: event.result });
|
|
194
210
|
});
|
|
195
211
|
pi.on("session_start", async (_event, context) => {
|
|
212
|
+
activateChildTools(pi);
|
|
196
213
|
server = http.createServer((request, response) => {
|
|
197
214
|
void (async () => {
|
|
198
215
|
try {
|