@dougbots/avenor-core 0.3.6 → 0.3.7
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/index.js +20 -15
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -447,26 +447,23 @@ function validateTimeout(value) {
|
|
|
447
447
|
return amount;
|
|
448
448
|
}
|
|
449
449
|
function validateSupervisorSocketPath(supervisorId) {
|
|
450
|
-
const canonical = fs.realpathSync(supervisorId);
|
|
451
450
|
const root = fs.realpathSync(socketsRoot());
|
|
452
|
-
const
|
|
453
|
-
|
|
454
|
-
|
|
451
|
+
const parent = fs.realpathSync(path.dirname(supervisorId));
|
|
452
|
+
const basename = path.basename(supervisorId);
|
|
453
|
+
if (parent !== root || !/^avenor-mcp-[^/\\]+\.sock$/.test(basename)) throw new Error(`invalid supervisorId: ${supervisorId}`);
|
|
454
|
+
return path.join(parent, basename);
|
|
455
455
|
}
|
|
456
456
|
//#endregion
|
|
457
457
|
//#region src/tools/get-supervisor-client.ts
|
|
458
458
|
async function getSupervisorClient(supervisorId) {
|
|
459
459
|
const id = validateSupervisorSocketPath(supervisorId);
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
supervisorId: id
|
|
468
|
-
};
|
|
469
|
-
}
|
|
460
|
+
const current = Supervisor.currentInstance();
|
|
461
|
+
if (current !== null && validateSupervisorSocketPath(current.supervisorId) === id) return {
|
|
462
|
+
client: current.getClient(),
|
|
463
|
+
isSingleton: true,
|
|
464
|
+
sup: current,
|
|
465
|
+
supervisorId: id
|
|
466
|
+
};
|
|
470
467
|
return {
|
|
471
468
|
client: await dial(id),
|
|
472
469
|
isSingleton: false,
|
|
@@ -624,10 +621,18 @@ async function buildRunStatus(client, runInfo, liveStatus) {
|
|
|
624
621
|
}
|
|
625
622
|
async function statusTool(args) {
|
|
626
623
|
if (args.supervisorId) {
|
|
627
|
-
const { client, isSingleton } = await getSupervisorClient(args.supervisorId);
|
|
624
|
+
const { client, isSingleton, sup } = await getSupervisorClient(args.supervisorId);
|
|
628
625
|
try {
|
|
629
626
|
if (args.runId) {
|
|
630
627
|
validateRunId(args.runId);
|
|
628
|
+
const runInfo = isSingleton && sup ? findRunByLabel$3(sup, args.runId) : void 0;
|
|
629
|
+
if (runInfo) {
|
|
630
|
+
let liveStatus = null;
|
|
631
|
+
if (runInfo.runtimeId) try {
|
|
632
|
+
liveStatus = await client.status(runInfo.runtimeId);
|
|
633
|
+
} catch {}
|
|
634
|
+
return buildRunStatus(client, runInfo, liveStatus);
|
|
635
|
+
}
|
|
631
636
|
let liveStatus = null;
|
|
632
637
|
try {
|
|
633
638
|
liveStatus = await client.status(args.runId);
|