pi-orchestrator-config 4.3.5 → 4.3.6
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.
|
@@ -921,55 +921,60 @@ export function registerAsyncAgents(
|
|
|
921
921
|
// Find the runner script
|
|
922
922
|
const runnerPath = path.join(path.dirname(fileURLToPath(import.meta.url)), "async-runner.ts");
|
|
923
923
|
|
|
924
|
-
// Find jiti for TypeScript execution
|
|
924
|
+
// Find jiti for TypeScript execution — walk UP from known roots until
|
|
925
|
+
// found; never assume a fixed depth (install layouts vary: dist/,
|
|
926
|
+
// dist/bundle/, workspace hoisting, nested node_modules).
|
|
925
927
|
let jitiCliPath: string | undefined;
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
} catch {
|
|
935
|
-
const entry = req.resolve("@earendil-works/pi-coding-agent");
|
|
936
|
-
let dir = path.dirname(entry);
|
|
937
|
-
while (dir !== path.dirname(dir)) {
|
|
938
|
-
const pj = path.join(dir, "package.json");
|
|
939
|
-
if (fs.existsSync(pj) && JSON.parse(fs.readFileSync(pj, "utf8"))?.name === "@earendil-works/pi-coding-agent") { piPkgJsonPath = pj; break; }
|
|
940
|
-
dir = path.dirname(dir);
|
|
941
|
-
}
|
|
928
|
+
const jitiProbes: string[] = [];
|
|
929
|
+
const findJitiUnder = (label: string, startDir: string): string | undefined => {
|
|
930
|
+
let dir = startDir;
|
|
931
|
+
while (dir !== path.dirname(dir)) {
|
|
932
|
+
const candidate = path.join(dir, "node_modules/jiti/lib/jiti-cli.mjs");
|
|
933
|
+
jitiProbes.push(`${fs.existsSync(candidate) ? "HIT" : "--"} ${candidate}`);
|
|
934
|
+
if (fs.existsSync(candidate)) return candidate;
|
|
935
|
+
dir = path.dirname(dir);
|
|
942
936
|
}
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
937
|
+
jitiProbes.push(`(exhausted from ${label}: ${startDir})`);
|
|
938
|
+
return undefined;
|
|
939
|
+
};
|
|
940
|
+
|
|
941
|
+
// Strategy 1: resolve from pi's own install location (the running binary).
|
|
942
|
+
try {
|
|
943
|
+
if (process.argv[1]) {
|
|
944
|
+
const piRoot = path.dirname(fs.realpathSync(process.argv[1]));
|
|
945
|
+
jitiCliPath = findJitiUnder("argv-binary", piRoot);
|
|
946
946
|
}
|
|
947
947
|
} catch (e: any) {
|
|
948
|
-
log.debug(`jiti strategy 1 (
|
|
948
|
+
log.debug(`jiti strategy 1 (running binary) failed: ${e?.message || e}`);
|
|
949
949
|
}
|
|
950
|
-
|
|
950
|
+
|
|
951
|
+
// Strategy 2: resolve the pi SDK package from this module's require context.
|
|
951
952
|
if (!jitiCliPath) {
|
|
952
953
|
try {
|
|
953
|
-
const
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
954
|
+
const req = createRequire(fileURLToPath(import.meta.url));
|
|
955
|
+
let sdkPkgJson: string | undefined;
|
|
956
|
+
try {
|
|
957
|
+
sdkPkgJson = req.resolve("@earendil-works/pi-coding-agent/package.json");
|
|
958
|
+
} catch {
|
|
959
|
+
// Newer SDK "exports" maps hide ./package.json — resolve the entry
|
|
960
|
+
// and walk up to the owning package.json instead.
|
|
961
|
+
let dir = path.dirname(req.resolve("@earendil-works/pi-coding-agent"));
|
|
962
|
+
while (dir !== path.dirname(dir)) {
|
|
963
|
+
const pj = path.join(dir, "package.json");
|
|
964
|
+
if (fs.existsSync(pj) && JSON.parse(fs.readFileSync(pj, "utf8"))?.name === "@earendil-works/pi-coding-agent") { sdkPkgJson = pj; break; }
|
|
965
|
+
dir = path.dirname(dir);
|
|
966
|
+
}
|
|
960
967
|
}
|
|
968
|
+
if (sdkPkgJson) jitiCliPath ??= findJitiUnder("sdk-pkg", path.dirname(sdkPkgJson));
|
|
961
969
|
} catch (e: any) {
|
|
962
|
-
log.debug(`jiti strategy 2 (
|
|
970
|
+
log.debug(`jiti strategy 2 (SDK package) failed: ${e?.message || e}`);
|
|
963
971
|
}
|
|
964
972
|
}
|
|
965
973
|
|
|
966
|
-
// Strategy 3: this package's own node_modules
|
|
967
|
-
// jiti themselves (npm consumers are covered by strategies 1-2).
|
|
974
|
+
// Strategy 3: this package's own node_modules (git/stow clones ship jiti).
|
|
968
975
|
if (!jitiCliPath) {
|
|
969
976
|
try {
|
|
970
|
-
|
|
971
|
-
const candidate = path.join(pkgRoot, "node_modules/jiti/lib/jiti-cli.mjs");
|
|
972
|
-
if (fs.existsSync(candidate)) jitiCliPath = candidate;
|
|
977
|
+
jitiCliPath = findJitiUnder("extension-dir", path.dirname(fileURLToPath(import.meta.url)));
|
|
973
978
|
} catch (e: any) {
|
|
974
979
|
log.debug(`jiti strategy 3 (package root) failed: ${e?.message || e}`);
|
|
975
980
|
}
|
|
@@ -978,7 +983,7 @@ export function registerAsyncAgents(
|
|
|
978
983
|
// Fail fast with a self-explanatory error instead of spawning a child that
|
|
979
984
|
// cannot load TypeScript (bare node dies on ".js"→".ts" specifiers).
|
|
980
985
|
if (!jitiCliPath) {
|
|
981
|
-
log.error(`async-spawn: ${id} — no jiti-cli.mjs found (
|
|
986
|
+
log.error(`async-spawn: ${id} — no jiti-cli.mjs found. Probes:\n ${(jitiProbes.slice(-14)).join("\n ")}`);
|
|
982
987
|
// Clean up the artifacts we already created — nothing will consume them.
|
|
983
988
|
try { fs.rmSync(configPath, { force: true }); } catch {}
|
|
984
989
|
try { fs.rmSync(workerDir, { recursive: true, force: true }); } catch {}
|