@xutest1/sdk 0.0.2 → 0.0.3

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.
Files changed (2) hide show
  1. package/dist/server.js +43 -2
  2. package/package.json +6 -8
package/dist/server.js CHANGED
@@ -1,11 +1,51 @@
1
1
  import { spawn } from "node:child_process";
2
+ import { existsSync } from "node:fs";
3
+ import { join, dirname } from "node:path";
4
+ import { fileURLToPath } from "node:url";
5
+ // Find the ae3code binary from optionalDependencies
6
+ function findBinary() {
7
+ const platform = process.platform;
8
+ const arch = process.arch;
9
+ const platformMap = {
10
+ 'darwin-arm64': '@xutest1/darwin-arm64',
11
+ 'darwin-x64': '@xutest1/darwin-x64',
12
+ 'linux-x64': '@xutest1/linux-x64',
13
+ 'linux-arm64': '@xutest1/linux-arm64',
14
+ 'win32-x64': '@xutest1/win32-x64',
15
+ };
16
+ const key = `${platform}-${arch}`;
17
+ const pkgName = platformMap[key];
18
+ if (!pkgName) {
19
+ console.warn(`No binary package for platform ${key}, falling back to PATH`);
20
+ return 'ae3code';
21
+ }
22
+ const binaryName = platform === 'win32' ? 'ae3code.exe' : 'ae3code';
23
+ // Try to find in node_modules relative to this file
24
+ const __dirname = dirname(fileURLToPath(import.meta.url));
25
+ const possiblePaths = [
26
+ // When installed as dependency: node_modules/@xutest1/sdk/dist -> node_modules/@xutest1/darwin-arm64/bin
27
+ join(__dirname, '..', '..', pkgName, 'bin', binaryName),
28
+ // Alternative path
29
+ join(__dirname, '..', '..', '..', pkgName, 'bin', binaryName),
30
+ // From cwd
31
+ join(process.cwd(), 'node_modules', pkgName, 'bin', binaryName),
32
+ ];
33
+ for (const p of possiblePaths) {
34
+ if (existsSync(p)) {
35
+ return p;
36
+ }
37
+ }
38
+ // Fallback to PATH
39
+ return 'ae3code';
40
+ }
2
41
  export async function createOpencodeServer(options) {
3
42
  options = Object.assign({
4
43
  hostname: "127.0.0.1",
5
44
  port: 4096,
6
45
  timeout: 5000,
7
46
  }, options ?? {});
8
- const proc = spawn(`ae3code`, [`serve`, `--hostname=${options.hostname}`, `--port=${options.port}`], {
47
+ const binaryPath = findBinary();
48
+ const proc = spawn(binaryPath, [`serve`, `--hostname=${options.hostname}`, `--port=${options.port}`], {
9
49
  signal: options.signal,
10
50
  env: {
11
51
  ...process.env,
@@ -75,7 +115,8 @@ export function createOpencodeTui(options) {
75
115
  if (options?.agent) {
76
116
  args.push(`--agent=${options.agent}`);
77
117
  }
78
- const proc = spawn(`ae3code`, args, {
118
+ const binaryPath = findBinary();
119
+ const proc = spawn(binaryPath, args, {
79
120
  signal: options?.signal,
80
121
  stdio: "inherit",
81
122
  env: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xutest1/sdk",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "A3Code SDK - Build AI agents with agentic coding capabilities",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -15,18 +15,16 @@
15
15
  "scripts": {
16
16
  "build": "tsc"
17
17
  },
18
- "dependencies": {
19
- },
20
18
  "devDependencies": {
21
19
  "@types/node": "^20.0.0",
22
20
  "typescript": "^5.0.0"
23
21
  },
24
22
  "optionalDependencies": {
25
- "@xutest1/darwin-arm64": "0.0.2",
26
- "@xutest1/darwin-x64": "0.0.2",
27
- "@xutest1/linux-x64": "0.0.2",
28
- "@xutest1/linux-arm64": "0.0.2",
29
- "@xutest1/win32-x64": "0.0.2"
23
+ "@xutest1/darwin-arm64": "0.0.3",
24
+ "@xutest1/darwin-x64": "0.0.3",
25
+ "@xutest1/linux-x64": "0.0.3",
26
+ "@xutest1/linux-arm64": "0.0.3",
27
+ "@xutest1/win32-x64": "0.0.3"
30
28
  },
31
29
  "keywords": ["a3code", "ai", "agent", "coding", "sdk", "vllm"],
32
30
  "license": "MIT"