@locusai/sdk 0.3.2 → 0.3.4

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.
@@ -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,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,qBAAa,iBAAkB,SAAQ,YAAY;IACjD,OAAO,CAAC,MAAM,CAAc;IAC5B,OAAO,CAAC,MAAM,CAAqB;IACnC,OAAO,CAAC,MAAM,CAAsC;IACpD,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,cAAc,CAA0B;IAChD,OAAO,CAAC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EAAE,MAAM,GACZ,OAAO,CAAC,IAAI,CAAC;IAyBhB;;OAEG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAM3B;;OAEG;YACW,OAAO;IAWrB;;OAEG;IACH,QAAQ;;;;;;IAeR,OAAO,CAAC,KAAK;CAGd"}
@@ -129,21 +129,28 @@ export class AgentOrchestrator extends EventEmitter {
129
129
  this.agents.set(agentId, agentState);
130
130
  console.log(`🚀 Agent started: ${agentId}\n`);
131
131
  // Build arguments for agent worker
132
- // Resolve path relative to this file's location (works in both dev and production)
133
- // Find package root to correctly resolve worker path
132
+ // Try multiple resolution strategies
133
+ const potentialPaths = [];
134
+ // Strategy 1: Use import.meta.resolve to find the installed SDK package
135
+ try {
136
+ // Resolve the SDK's index to find the package location
137
+ const sdkIndexPath = import.meta.resolve("@locusai/sdk");
138
+ const sdkDir = dirname(sdkIndexPath.replace("file://", ""));
139
+ // In production, files are in dist/; sdkDir points to dist/ or src/
140
+ const sdkRoot = this.findPackageRoot(sdkDir);
141
+ potentialPaths.push(join(sdkRoot, "dist", "agent", "worker.js"), join(sdkRoot, "src", "agent", "worker.ts"));
142
+ }
143
+ catch {
144
+ // import.meta.resolve failed, continue with fallback strategies
145
+ }
146
+ // Strategy 2: Find package root from __dirname (works in dev/local)
134
147
  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
- ];
148
+ potentialPaths.push(join(packageRoot, "dist", "agent", "worker.js"), join(packageRoot, "src", "agent", "worker.ts"), join(__dirname, "agent", "worker.ts"), join(__dirname, "agent", "worker.js"));
142
149
  const workerPath = potentialPaths.find((p) => existsSync(p));
143
150
  // Verify worker file exists
144
151
  if (!workerPath) {
145
152
  throw new Error(`Worker file not found. Checked: ${potentialPaths.join(", ")}. ` +
146
- `Make sure the SDK is properly built. __dirname: ${__dirname}, Package Root: ${packageRoot}`);
153
+ `Make sure the SDK is properly built and installed.`);
147
154
  }
148
155
  const workerArgs = [
149
156
  "--agent-id",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@locusai/sdk",
3
- "version": "0.3.2",
3
+ "version": "0.3.4",
4
4
  "type": "module",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./src/index.ts",
@@ -41,7 +41,7 @@
41
41
  },
42
42
  "dependencies": {
43
43
  "@anthropic-ai/sdk": "^0.71.2",
44
- "@locusai/shared": "workspace:*",
44
+ "@locusai/shared": "^0.3.4",
45
45
  "axios": "^1.13.2",
46
46
  "events": "^3.3.0",
47
47
  "globby": "^14.0.2"
@@ -178,17 +178,32 @@ export class AgentOrchestrator extends EventEmitter {
178
178
  console.log(`🚀 Agent started: ${agentId}\n`);
179
179
 
180
180
  // Build arguments for agent worker
181
- // Resolve path relative to this file's location (works in both dev and production)
182
- // Find package root to correctly resolve worker path
183
- const packageRoot = this.findPackageRoot(__dirname);
181
+ // Try multiple resolution strategies
182
+ const potentialPaths: string[] = [];
184
183
 
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
- ];
184
+ // Strategy 1: Use import.meta.resolve to find the installed SDK package
185
+ try {
186
+ // Resolve the SDK's index to find the package location
187
+ const sdkIndexPath = import.meta.resolve("@locusai/sdk");
188
+ const sdkDir = dirname(sdkIndexPath.replace("file://", ""));
189
+ // In production, files are in dist/; sdkDir points to dist/ or src/
190
+ const sdkRoot = this.findPackageRoot(sdkDir);
191
+ potentialPaths.push(
192
+ join(sdkRoot, "dist", "agent", "worker.js"),
193
+ join(sdkRoot, "src", "agent", "worker.ts")
194
+ );
195
+ } catch {
196
+ // import.meta.resolve failed, continue with fallback strategies
197
+ }
198
+
199
+ // Strategy 2: Find package root from __dirname (works in dev/local)
200
+ const packageRoot = this.findPackageRoot(__dirname);
201
+ potentialPaths.push(
202
+ join(packageRoot, "dist", "agent", "worker.js"),
203
+ join(packageRoot, "src", "agent", "worker.ts"),
204
+ join(__dirname, "agent", "worker.ts"),
205
+ join(__dirname, "agent", "worker.js")
206
+ );
192
207
 
193
208
  const workerPath = potentialPaths.find((p) => existsSync(p));
194
209
 
@@ -196,7 +211,7 @@ export class AgentOrchestrator extends EventEmitter {
196
211
  if (!workerPath) {
197
212
  throw new Error(
198
213
  `Worker file not found. Checked: ${potentialPaths.join(", ")}. ` +
199
- `Make sure the SDK is properly built. __dirname: ${__dirname}, Package Root: ${packageRoot}`
214
+ `Make sure the SDK is properly built and installed.`
200
215
  );
201
216
  }
202
217