@sjawhar/pi-legion-envoy 1.34.0 → 1.35.1
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/envoy.js +56 -34
- package/dist/legion.js +224 -4427
- package/dist/skills/legion-architect/SKILL.md +16 -9
- package/dist/skills/legion-controller/SKILL.md +235 -17
- package/dist/skills/legion-worker/SKILL.md +9 -5
- package/package.json +2 -2
package/dist/envoy.js
CHANGED
|
@@ -30348,7 +30348,7 @@ var LegionDaemonApi = {
|
|
|
30348
30348
|
queue: array(nonEmptyString)
|
|
30349
30349
|
}),
|
|
30350
30350
|
gates: record(string2(), stateGate),
|
|
30351
|
-
controllerLocator:
|
|
30351
|
+
controllerLocator: stateTreeLocator.optional(),
|
|
30352
30352
|
roles: record(string2(), stateRole),
|
|
30353
30353
|
controllerPendingNotices: number2().int().nonnegative(),
|
|
30354
30354
|
pendingStatusWrites: array(nonEmptyString),
|
|
@@ -30356,7 +30356,11 @@ var LegionDaemonApi = {
|
|
|
30356
30356
|
})
|
|
30357
30357
|
},
|
|
30358
30358
|
ControllerReady: {
|
|
30359
|
-
request: strictObject({
|
|
30359
|
+
request: strictObject({
|
|
30360
|
+
secret: nonEmptyString,
|
|
30361
|
+
sessionId: nonEmptyString,
|
|
30362
|
+
ompSessionFile: nonEmptyString.optional()
|
|
30363
|
+
}),
|
|
30360
30364
|
response: object({})
|
|
30361
30365
|
},
|
|
30362
30366
|
ProcessStarted: {
|
|
@@ -30476,17 +30480,23 @@ var LegionDaemonApi = {
|
|
|
30476
30480
|
response: object({})
|
|
30477
30481
|
},
|
|
30478
30482
|
Grant: {
|
|
30479
|
-
request:
|
|
30480
|
-
|
|
30481
|
-
|
|
30482
|
-
|
|
30483
|
-
|
|
30484
|
-
|
|
30483
|
+
request: union([
|
|
30484
|
+
strictObject({
|
|
30485
|
+
sessionId: nonEmptyString,
|
|
30486
|
+
secret: nonEmptyString,
|
|
30487
|
+
tree: nonEmptyString,
|
|
30488
|
+
issue: nonEmptyString
|
|
30489
|
+
}),
|
|
30490
|
+
strictObject({ sessionId: nonEmptyString, secret: nonEmptyString })
|
|
30491
|
+
]),
|
|
30485
30492
|
response: object({ grantId: nonEmptyString, expiresAt: nonEmptyString })
|
|
30486
30493
|
},
|
|
30487
30494
|
GitHubToken: {
|
|
30488
|
-
request: strictObject({ grantId: nonEmptyString }),
|
|
30495
|
+
request: strictObject({ grantId: nonEmptyString, merge: literal(true).optional() }),
|
|
30489
30496
|
response: object({ token: nonEmptyString, appLogin: string2().endsWith("[bot]") })
|
|
30497
|
+
},
|
|
30498
|
+
GitCredential: {
|
|
30499
|
+
request: strictObject({ grantId: nonEmptyString })
|
|
30490
30500
|
}
|
|
30491
30501
|
};
|
|
30492
30502
|
// ../contracts/src/repo.ts
|
|
@@ -33253,6 +33263,31 @@ function messageMetadata(input) {
|
|
|
33253
33263
|
import { logger } from "@oh-my-pi/pi-utils";
|
|
33254
33264
|
var import_nats = __toESM(require_mod4(), 1);
|
|
33255
33265
|
|
|
33266
|
+
// src/legion/role-claim-bridge.ts
|
|
33267
|
+
var LEGION_ROLE_CLAIM_BRIDGE = Symbol.for("legion.pi-envoy.role-claim-bridge");
|
|
33268
|
+
function legionRoleClaimBridge() {
|
|
33269
|
+
const store = globalThis;
|
|
33270
|
+
const bridge = store[LEGION_ROLE_CLAIM_BRIDGE];
|
|
33271
|
+
if (bridge)
|
|
33272
|
+
return bridge;
|
|
33273
|
+
const createdBridge = {
|
|
33274
|
+
instances: [],
|
|
33275
|
+
regained: undefined
|
|
33276
|
+
};
|
|
33277
|
+
store[LEGION_ROLE_CLAIM_BRIDGE] = createdBridge;
|
|
33278
|
+
return createdBridge;
|
|
33279
|
+
}
|
|
33280
|
+
async function claimEnvoyRole(sessionID, role, context) {
|
|
33281
|
+
const bridge = legionRoleClaimBridge();
|
|
33282
|
+
const instance = bridge.instances.findLast((candidate) => candidate.sessionID() === sessionID) ?? bridge.instances.at(-1);
|
|
33283
|
+
if (instance === undefined)
|
|
33284
|
+
throw new Error("Envoy has no bound instance for a role claim");
|
|
33285
|
+
await instance.claim(sessionID, role, context);
|
|
33286
|
+
}
|
|
33287
|
+
function onEnvoyRoleRegained(listener) {
|
|
33288
|
+
legionRoleClaimBridge().regained = listener;
|
|
33289
|
+
}
|
|
33290
|
+
|
|
33256
33291
|
// src/tool-result.ts
|
|
33257
33292
|
function toolSuccess(text, details = {}) {
|
|
33258
33293
|
return { content: [{ type: "text", text }], details };
|
|
@@ -33334,25 +33369,6 @@ function isRoleClaimEntry(entry) {
|
|
|
33334
33369
|
return false;
|
|
33335
33370
|
return entry.data.role === null || typeof entry.data.role === "string";
|
|
33336
33371
|
}
|
|
33337
|
-
var LEGION_ROLE_CLAIM_BRIDGE = Symbol.for("legion.pi-envoy.role-claim-bridge");
|
|
33338
|
-
function legionRoleClaimBridge() {
|
|
33339
|
-
const store = globalThis;
|
|
33340
|
-
let bridge = store[LEGION_ROLE_CLAIM_BRIDGE];
|
|
33341
|
-
if (bridge === undefined) {
|
|
33342
|
-
const ready = Promise.withResolvers();
|
|
33343
|
-
bridge = { ready };
|
|
33344
|
-
store[LEGION_ROLE_CLAIM_BRIDGE] = bridge;
|
|
33345
|
-
}
|
|
33346
|
-
return bridge;
|
|
33347
|
-
}
|
|
33348
|
-
async function claimEnvoyRole(sessionID, role, context) {
|
|
33349
|
-
const bridge = legionRoleClaimBridge();
|
|
33350
|
-
const claim = bridge.claim ?? await bridge.ready.promise;
|
|
33351
|
-
await claim(sessionID, role, context);
|
|
33352
|
-
}
|
|
33353
|
-
function onEnvoyRoleRegained(listener) {
|
|
33354
|
-
legionRoleClaimBridge().regained = listener;
|
|
33355
|
-
}
|
|
33356
33372
|
function resolveSkillsDirectory() {
|
|
33357
33373
|
const moduleDirectory = dirname(fileURLToPath(import.meta.url));
|
|
33358
33374
|
const candidates = [
|
|
@@ -33450,7 +33466,9 @@ function envoyExtension(pi) {
|
|
|
33450
33466
|
};
|
|
33451
33467
|
const deliver = async (subject, raw, reply) => {
|
|
33452
33468
|
const rendered = renderInbound(raw, sessionID, subject);
|
|
33453
|
-
|
|
33469
|
+
const directSubject = agentSubject(sessionID);
|
|
33470
|
+
const envelopeTopic = rendered.envelope?.topic;
|
|
33471
|
+
if (reply !== "" && subject === directSubject && envelopeTopic !== undefined && envelopeTopic !== directSubject) {
|
|
33454
33472
|
try {
|
|
33455
33473
|
(await ensureConnection()).publish(reply);
|
|
33456
33474
|
} catch (error) {
|
|
@@ -33788,8 +33806,11 @@ function envoyExtension(pi) {
|
|
|
33788
33806
|
await registerSession();
|
|
33789
33807
|
await setEnvoyRole(role);
|
|
33790
33808
|
};
|
|
33791
|
-
|
|
33792
|
-
|
|
33809
|
+
const claimInstance = {
|
|
33810
|
+
claim,
|
|
33811
|
+
sessionID: () => activeSessionContext?.sessionManager.getSessionId() ?? sessionID
|
|
33812
|
+
};
|
|
33813
|
+
bridge.instances.push(claimInstance);
|
|
33793
33814
|
pi.on("session_start", async (_event, context) => {
|
|
33794
33815
|
const previousSessionID = sessionID;
|
|
33795
33816
|
restoreLocalSessionState(context);
|
|
@@ -33858,6 +33879,9 @@ function envoyExtension(pi) {
|
|
|
33858
33879
|
pi.on("session_tree", (_event, context) => rebind(undefined, context));
|
|
33859
33880
|
pi.on("session_shutdown", async () => {
|
|
33860
33881
|
shuttingDown = true;
|
|
33882
|
+
const bound = bridge.instances.indexOf(claimInstance);
|
|
33883
|
+
if (bound !== -1)
|
|
33884
|
+
bridge.instances.splice(bound, 1);
|
|
33861
33885
|
const deadline = Promise.withResolvers();
|
|
33862
33886
|
const timer = setTimeout(deadline.resolve, 1000);
|
|
33863
33887
|
try {
|
|
@@ -34126,7 +34150,5 @@ function topicsFor(parameters, fallback = []) {
|
|
|
34126
34150
|
return expandSubscriptionTopics(value);
|
|
34127
34151
|
}
|
|
34128
34152
|
export {
|
|
34129
|
-
|
|
34130
|
-
envoyExtension as default,
|
|
34131
|
-
onEnvoyRoleRegained
|
|
34153
|
+
envoyExtension as default
|
|
34132
34154
|
};
|