@locusai/sdk 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/dist/orchestrator.d.ts +4 -0
- package/dist/orchestrator.d.ts.map +1 -1
- package/dist/orchestrator.js +30 -8
- package/package.json +1 -1
- package/src/orchestrator.ts +33 -8
package/dist/orchestrator.d.ts
CHANGED
|
@@ -44,6 +44,10 @@ export declare class AgentOrchestrator extends EventEmitter {
|
|
|
44
44
|
* Main orchestration loop - runs 1 agent continuously
|
|
45
45
|
*/
|
|
46
46
|
private orchestrationLoop;
|
|
47
|
+
/**
|
|
48
|
+
* Find the package root by looking for package.json
|
|
49
|
+
*/
|
|
50
|
+
private findPackageRoot;
|
|
47
51
|
/**
|
|
48
52
|
* Spawn a single agent process
|
|
49
53
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"orchestrator.d.ts","sourceRoot":"","sources":["../src/orchestrator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAS,MAAM,oBAAoB,CAAC;AAGzD,OAAO,EAAE,IAAI,EAA4B,MAAM,iBAAiB,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAGtC,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,kBAAkB,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,WAAW,GAAG,QAAQ,CAAC;IACpD,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,IAAI,CAAC;IACpB,OAAO,CAAC,EAAE,YAAY,CAAC;CACxB;AAED,MAAM,WAAW,kBAAkB;IACjC,WAAW,EAAE,MAAM,CAAC;IACpB,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;;;IAeR,OAAO,CAAC,KAAK;CAGd"}
|
package/dist/orchestrator.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { spawn } from "node:child_process";
|
|
2
2
|
import { existsSync } from "node:fs";
|
|
3
|
-
import { join } from "node:path";
|
|
3
|
+
import { dirname, join } from "node:path";
|
|
4
4
|
import { TaskPriority, TaskStatus } from "@locusai/shared";
|
|
5
5
|
import { EventEmitter } from "events";
|
|
6
6
|
import { LocusClient } from "./index";
|
|
@@ -97,6 +97,20 @@ export class AgentOrchestrator extends EventEmitter {
|
|
|
97
97
|
}
|
|
98
98
|
console.log("\nā
Orchestrator finished");
|
|
99
99
|
}
|
|
100
|
+
/**
|
|
101
|
+
* Find the package root by looking for package.json
|
|
102
|
+
*/
|
|
103
|
+
findPackageRoot(startPath) {
|
|
104
|
+
let currentDir = startPath;
|
|
105
|
+
while (currentDir !== "/") {
|
|
106
|
+
if (existsSync(join(currentDir, "package.json"))) {
|
|
107
|
+
return currentDir;
|
|
108
|
+
}
|
|
109
|
+
currentDir = dirname(currentDir);
|
|
110
|
+
}
|
|
111
|
+
// Fallback to startPath if not found
|
|
112
|
+
return startPath;
|
|
113
|
+
}
|
|
100
114
|
/**
|
|
101
115
|
* Spawn a single agent process
|
|
102
116
|
*/
|
|
@@ -116,11 +130,20 @@ export class AgentOrchestrator extends EventEmitter {
|
|
|
116
130
|
console.log(`š Agent started: ${agentId}\n`);
|
|
117
131
|
// Build arguments for agent worker
|
|
118
132
|
// Resolve path relative to this file's location (works in both dev and production)
|
|
119
|
-
|
|
133
|
+
// Find package root to correctly resolve worker path
|
|
134
|
+
const packageRoot = this.findPackageRoot(__dirname);
|
|
135
|
+
// Check possible locations for the worker file relative to package root
|
|
136
|
+
const potentialPaths = [
|
|
137
|
+
join(packageRoot, "dist", "agent", "worker.js"), // Production
|
|
138
|
+
join(packageRoot, "src", "agent", "worker.ts"), // Development
|
|
139
|
+
join(__dirname, "agent", "worker.ts"), // Fallback relative (dev)
|
|
140
|
+
join(__dirname, "agent", "worker.js"), // Fallback relative (prod)
|
|
141
|
+
];
|
|
142
|
+
const workerPath = potentialPaths.find((p) => existsSync(p));
|
|
120
143
|
// Verify worker file exists
|
|
121
|
-
if (!
|
|
122
|
-
throw new Error(`Worker file not found
|
|
123
|
-
`Make sure the SDK is properly built. __dirname: ${__dirname}`);
|
|
144
|
+
if (!workerPath) {
|
|
145
|
+
throw new Error(`Worker file not found. Checked: ${potentialPaths.join(", ")}. ` +
|
|
146
|
+
`Make sure the SDK is properly built. __dirname: ${__dirname}, Package Root: ${packageRoot}`);
|
|
124
147
|
}
|
|
125
148
|
const workerArgs = [
|
|
126
149
|
"--agent-id",
|
|
@@ -146,9 +169,8 @@ export class AgentOrchestrator extends EventEmitter {
|
|
|
146
169
|
if (this.resolvedSprintId) {
|
|
147
170
|
workerArgs.push("--sprint-id", this.resolvedSprintId);
|
|
148
171
|
}
|
|
149
|
-
// Use bun to run
|
|
150
|
-
const
|
|
151
|
-
const agentProcess = spawn("bun", ["run", workerTsPath, ...workerArgs]);
|
|
172
|
+
// Use bun to run the worker script
|
|
173
|
+
const agentProcess = spawn("bun", ["run", workerPath, ...workerArgs]);
|
|
152
174
|
agentState.process = agentProcess;
|
|
153
175
|
agentProcess.on("message", (msg) => {
|
|
154
176
|
if (msg.type === "stats") {
|
package/package.json
CHANGED
package/src/orchestrator.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ChildProcess, spawn } from "node:child_process";
|
|
2
2
|
import { existsSync } from "node:fs";
|
|
3
|
-
import { join } from "node:path";
|
|
3
|
+
import { dirname, join } from "node:path";
|
|
4
4
|
import { Task, TaskPriority, TaskStatus } from "@locusai/shared";
|
|
5
5
|
import { EventEmitter } from "events";
|
|
6
6
|
import { LocusClient } from "./index";
|
|
@@ -141,6 +141,21 @@ export class AgentOrchestrator extends EventEmitter {
|
|
|
141
141
|
console.log("\nā
Orchestrator finished");
|
|
142
142
|
}
|
|
143
143
|
|
|
144
|
+
/**
|
|
145
|
+
* Find the package root by looking for package.json
|
|
146
|
+
*/
|
|
147
|
+
private findPackageRoot(startPath: string): string {
|
|
148
|
+
let currentDir = startPath;
|
|
149
|
+
while (currentDir !== "/") {
|
|
150
|
+
if (existsSync(join(currentDir, "package.json"))) {
|
|
151
|
+
return currentDir;
|
|
152
|
+
}
|
|
153
|
+
currentDir = dirname(currentDir);
|
|
154
|
+
}
|
|
155
|
+
// Fallback to startPath if not found
|
|
156
|
+
return startPath;
|
|
157
|
+
}
|
|
158
|
+
|
|
144
159
|
/**
|
|
145
160
|
* Spawn a single agent process
|
|
146
161
|
*/
|
|
@@ -164,13 +179,24 @@ export class AgentOrchestrator extends EventEmitter {
|
|
|
164
179
|
|
|
165
180
|
// Build arguments for agent worker
|
|
166
181
|
// Resolve path relative to this file's location (works in both dev and production)
|
|
167
|
-
|
|
182
|
+
// Find package root to correctly resolve worker path
|
|
183
|
+
const packageRoot = this.findPackageRoot(__dirname);
|
|
184
|
+
|
|
185
|
+
// Check possible locations for the worker file relative to package root
|
|
186
|
+
const potentialPaths = [
|
|
187
|
+
join(packageRoot, "dist", "agent", "worker.js"), // Production
|
|
188
|
+
join(packageRoot, "src", "agent", "worker.ts"), // Development
|
|
189
|
+
join(__dirname, "agent", "worker.ts"), // Fallback relative (dev)
|
|
190
|
+
join(__dirname, "agent", "worker.js"), // Fallback relative (prod)
|
|
191
|
+
];
|
|
192
|
+
|
|
193
|
+
const workerPath = potentialPaths.find((p) => existsSync(p));
|
|
168
194
|
|
|
169
195
|
// Verify worker file exists
|
|
170
|
-
if (!
|
|
196
|
+
if (!workerPath) {
|
|
171
197
|
throw new Error(
|
|
172
|
-
`Worker file not found
|
|
173
|
-
`Make sure the SDK is properly built. __dirname: ${__dirname}`
|
|
198
|
+
`Worker file not found. Checked: ${potentialPaths.join(", ")}. ` +
|
|
199
|
+
`Make sure the SDK is properly built. __dirname: ${__dirname}, Package Root: ${packageRoot}`
|
|
174
200
|
);
|
|
175
201
|
}
|
|
176
202
|
|
|
@@ -202,9 +228,8 @@ export class AgentOrchestrator extends EventEmitter {
|
|
|
202
228
|
workerArgs.push("--sprint-id", this.resolvedSprintId);
|
|
203
229
|
}
|
|
204
230
|
|
|
205
|
-
// Use bun to run
|
|
206
|
-
const
|
|
207
|
-
const agentProcess = spawn("bun", ["run", workerTsPath, ...workerArgs]);
|
|
231
|
+
// Use bun to run the worker script
|
|
232
|
+
const agentProcess = spawn("bun", ["run", workerPath, ...workerArgs]);
|
|
208
233
|
|
|
209
234
|
agentState.process = agentProcess;
|
|
210
235
|
|