@sjawhar/pi-legion-envoy 5.30.11 → 5.30.13
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/dist/legion.js +38 -4
- package/package.json +1 -1
package/dist/legion.js
CHANGED
|
@@ -33834,7 +33834,7 @@ import { logger } from "@oh-my-pi/pi-utils";
|
|
|
33834
33834
|
// package.json
|
|
33835
33835
|
var package_default = {
|
|
33836
33836
|
name: "@sjawhar/pi-legion-envoy",
|
|
33837
|
-
version: "5.30.
|
|
33837
|
+
version: "5.30.13",
|
|
33838
33838
|
type: "module",
|
|
33839
33839
|
omp: {
|
|
33840
33840
|
extensions: [
|
|
@@ -35287,6 +35287,28 @@ function restorePhaseStall(branch) {
|
|
|
35287
35287
|
return "closed";
|
|
35288
35288
|
}
|
|
35289
35289
|
|
|
35290
|
+
// src/legion/session-title.ts
|
|
35291
|
+
function legionSessionTitle(session, project) {
|
|
35292
|
+
switch (session.kind) {
|
|
35293
|
+
case "controller":
|
|
35294
|
+
return project ? `Legion controller \xB7 ${project.toUpperCase()}` : "Legion controller";
|
|
35295
|
+
case "root-architect":
|
|
35296
|
+
return `Legion architect \xB7 ${session.tree}`;
|
|
35297
|
+
case "phase-worker":
|
|
35298
|
+
return `Legion ${session.role} \xB7 ${session.issue}`;
|
|
35299
|
+
case "not-legion":
|
|
35300
|
+
return;
|
|
35301
|
+
}
|
|
35302
|
+
}
|
|
35303
|
+
async function applySessionTitle(pi, context, title) {
|
|
35304
|
+
const current = context.sessionManager.getSessionName?.();
|
|
35305
|
+
if (current === title)
|
|
35306
|
+
return;
|
|
35307
|
+
if (current && context.sessionManager.getHeader?.()?.titleSource !== "auto")
|
|
35308
|
+
return;
|
|
35309
|
+
await pi.setSessionName(title);
|
|
35310
|
+
}
|
|
35311
|
+
|
|
35290
35312
|
// src/legion/tools.ts
|
|
35291
35313
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
35292
35314
|
var jsonSuccess2 = (details) => toolSuccess(JSON.stringify(details), details);
|
|
@@ -35986,9 +36008,15 @@ function legionExtension(pi) {
|
|
|
35986
36008
|
throw error48;
|
|
35987
36009
|
}
|
|
35988
36010
|
};
|
|
36011
|
+
const titleSession = async (context) => {
|
|
36012
|
+
const title = legionSessionTitle(classifySession(process.env), process.env.LEGION_PROJECT);
|
|
36013
|
+
if (title !== undefined)
|
|
36014
|
+
await applySessionTitle(pi, context, title);
|
|
36015
|
+
};
|
|
35989
36016
|
pi.on("session_start", async (_event, context) => {
|
|
35990
36017
|
if (await checkSubagentSession(context))
|
|
35991
36018
|
return;
|
|
36019
|
+
await titleSession(context);
|
|
35992
36020
|
phaseStall = restorePhaseStall(context.sessionManager.getBranch?.() ?? []);
|
|
35993
36021
|
if (process.env.LEGION_DAEMON_API === "go") {
|
|
35994
36022
|
if (classifySession(process.env).kind === "controller") {
|
|
@@ -36028,9 +36056,15 @@ function legionExtension(pi) {
|
|
|
36028
36056
|
return;
|
|
36029
36057
|
}
|
|
36030
36058
|
});
|
|
36031
|
-
|
|
36032
|
-
|
|
36033
|
-
|
|
36059
|
+
const afterSessionChange = async (context) => {
|
|
36060
|
+
if (classifySession(process.env).kind === "controller" && !await checkSubagentSession(context)) {
|
|
36061
|
+
await titleSession(context);
|
|
36062
|
+
}
|
|
36063
|
+
await controllerSession.reclaimAfterSessionChange(context);
|
|
36064
|
+
};
|
|
36065
|
+
pi.on("session_switch", (_event, context) => afterSessionChange(context));
|
|
36066
|
+
pi.on("session_branch", (_event, context) => afterSessionChange(context));
|
|
36067
|
+
pi.on("session_tree", (_event, context) => afterSessionChange(context));
|
|
36034
36068
|
pi.on("tool_call", async (toolCall, context) => {
|
|
36035
36069
|
logger.debug("legion tool_call hook", {
|
|
36036
36070
|
instance,
|