@locusai/cli 0.3.0 → 0.3.2
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/bin/locus.js +24 -8
- package/package.json +1 -1
package/bin/locus.js
CHANGED
|
@@ -17026,7 +17026,7 @@ var require_follow_redirects = __commonJS((exports, module) => {
|
|
|
17026
17026
|
|
|
17027
17027
|
// src/cli.ts
|
|
17028
17028
|
import { existsSync as existsSync6, readFileSync as readFileSync5 } from "node:fs";
|
|
17029
|
-
import { dirname as
|
|
17029
|
+
import { dirname as dirname3, join as join6 } from "node:path";
|
|
17030
17030
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
17031
17031
|
import { parseArgs } from "node:util";
|
|
17032
17032
|
|
|
@@ -30543,7 +30543,7 @@ if (process.argv[1]?.includes("agent-worker") || process.argv[1]?.includes("work
|
|
|
30543
30543
|
// ../sdk/src/orchestrator.ts
|
|
30544
30544
|
import { spawn as spawn2 } from "node:child_process";
|
|
30545
30545
|
import { existsSync as existsSync4 } from "node:fs";
|
|
30546
|
-
import { join as join4 } from "node:path";
|
|
30546
|
+
import { dirname as dirname2, join as join4 } from "node:path";
|
|
30547
30547
|
import { EventEmitter as EventEmitter3 } from "events";
|
|
30548
30548
|
var __dirname = "/home/runner/work/locusai/locusai/packages/sdk/src";
|
|
30549
30549
|
|
|
@@ -30624,6 +30624,16 @@ class AgentOrchestrator extends EventEmitter3 {
|
|
|
30624
30624
|
console.log(`
|
|
30625
30625
|
✅ Orchestrator finished`);
|
|
30626
30626
|
}
|
|
30627
|
+
findPackageRoot(startPath) {
|
|
30628
|
+
let currentDir = startPath;
|
|
30629
|
+
while (currentDir !== "/") {
|
|
30630
|
+
if (existsSync4(join4(currentDir, "package.json"))) {
|
|
30631
|
+
return currentDir;
|
|
30632
|
+
}
|
|
30633
|
+
currentDir = dirname2(currentDir);
|
|
30634
|
+
}
|
|
30635
|
+
return startPath;
|
|
30636
|
+
}
|
|
30627
30637
|
async spawnAgent() {
|
|
30628
30638
|
const agentId = `agent-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;
|
|
30629
30639
|
const agentState = {
|
|
@@ -30637,9 +30647,16 @@ class AgentOrchestrator extends EventEmitter3 {
|
|
|
30637
30647
|
this.agents.set(agentId, agentState);
|
|
30638
30648
|
console.log(`\uD83D\uDE80 Agent started: ${agentId}
|
|
30639
30649
|
`);
|
|
30640
|
-
const
|
|
30641
|
-
|
|
30642
|
-
|
|
30650
|
+
const packageRoot = this.findPackageRoot(__dirname);
|
|
30651
|
+
const potentialPaths = [
|
|
30652
|
+
join4(packageRoot, "dist", "agent", "worker.js"),
|
|
30653
|
+
join4(packageRoot, "src", "agent", "worker.ts"),
|
|
30654
|
+
join4(__dirname, "agent", "worker.ts"),
|
|
30655
|
+
join4(__dirname, "agent", "worker.js")
|
|
30656
|
+
];
|
|
30657
|
+
const workerPath = potentialPaths.find((p) => existsSync4(p));
|
|
30658
|
+
if (!workerPath) {
|
|
30659
|
+
throw new Error(`Worker file not found. Checked: ${potentialPaths.join(", ")}. ` + `Make sure the SDK is properly built. __dirname: ${__dirname}, Package Root: ${packageRoot}`);
|
|
30643
30660
|
}
|
|
30644
30661
|
const workerArgs = [
|
|
30645
30662
|
"--agent-id",
|
|
@@ -30662,8 +30679,7 @@ class AgentOrchestrator extends EventEmitter3 {
|
|
|
30662
30679
|
if (this.resolvedSprintId) {
|
|
30663
30680
|
workerArgs.push("--sprint-id", this.resolvedSprintId);
|
|
30664
30681
|
}
|
|
30665
|
-
const
|
|
30666
|
-
const agentProcess = spawn2("bun", ["run", workerTsPath, ...workerArgs]);
|
|
30682
|
+
const agentProcess = spawn2("bun", ["run", workerPath, ...workerArgs]);
|
|
30667
30683
|
agentState.process = agentProcess;
|
|
30668
30684
|
agentProcess.on("message", (msg) => {
|
|
30669
30685
|
if (msg.type === "stats") {
|
|
@@ -30898,7 +30914,7 @@ ${tree}`;
|
|
|
30898
30914
|
function getVersion() {
|
|
30899
30915
|
try {
|
|
30900
30916
|
const __filename2 = fileURLToPath2(import.meta.url);
|
|
30901
|
-
const __dirname2 =
|
|
30917
|
+
const __dirname2 = dirname3(__filename2);
|
|
30902
30918
|
const packagePath = join6(__dirname2, "..", "package.json");
|
|
30903
30919
|
if (existsSync6(packagePath)) {
|
|
30904
30920
|
const pkg = JSON.parse(readFileSync5(packagePath, "utf-8"));
|