@agi-cli/sdk 0.1.91 → 0.1.93

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agi-cli/sdk",
3
- "version": "0.1.91",
3
+ "version": "0.1.93",
4
4
  "description": "AI agent SDK for building intelligent assistants - tree-shakable and comprehensive",
5
5
  "author": "ntishxyz",
6
6
  "license": "MIT",
@@ -1,7 +1,7 @@
1
1
  import { existsSync, mkdirSync } from 'node:fs';
2
- import { dirname, join } from 'node:path';
3
- import { fileURLToPath } from 'node:url';
4
- import { tmpdir } from 'node:os';
2
+ import { join } from 'node:path';
3
+ import { getGlobalConfigDir } from '../../../../src/config/src/paths.ts';
4
+ import { RUST_PTY_LIBS } from './rust-libs.ts';
5
5
 
6
6
  function resolveLibraryFilename(): string {
7
7
  const platform = process.platform;
@@ -27,22 +27,6 @@ function tryUseExistingPath(path?: string | null): string | null {
27
27
  return null;
28
28
  }
29
29
 
30
- async function readFromEmbedded(
31
- url: URL,
32
- targetPath: string,
33
- ): Promise<string | null> {
34
- const file = Bun.file(url);
35
- if (!(await file.exists())) {
36
- return null;
37
- }
38
-
39
- const dir = dirname(targetPath);
40
- mkdirSync(dir, { recursive: true });
41
- await Bun.write(targetPath, file);
42
- process.env.BUN_PTY_LIB = targetPath;
43
- return targetPath;
44
- }
45
-
46
30
  export async function ensureBunPtyLibrary(): Promise<string | null> {
47
31
  const already = tryUseExistingPath(process.env.BUN_PTY_LIB);
48
32
  if (already) return already;
@@ -50,19 +34,6 @@ export async function ensureBunPtyLibrary(): Promise<string | null> {
50
34
  const filename = resolveLibraryFilename();
51
35
  const candidates: string[] = [];
52
36
 
53
- let pkgUrl: string | null = null;
54
- try {
55
- pkgUrl = await import.meta.resolve('bun-pty/package.json');
56
- const pkgPath = fileURLToPath(pkgUrl);
57
- const pkgDir = dirname(pkgPath);
58
- candidates.push(
59
- join(pkgDir, 'rust-pty', 'target', 'release', filename),
60
- join(pkgDir, '..', 'bun-pty', 'rust-pty', 'target', 'release', filename),
61
- );
62
- } catch {
63
- // ignore resolution failures
64
- }
65
-
66
37
  candidates.push(
67
38
  join(
68
39
  process.cwd(),
@@ -80,14 +51,19 @@ export async function ensureBunPtyLibrary(): Promise<string | null> {
80
51
  if (path) return path;
81
52
  }
82
53
 
83
- if (pkgUrl) {
84
- const embeddedUrl = new URL(
85
- `./rust-pty/target/release/${filename}`,
86
- pkgUrl,
87
- );
88
- const tmpPath = join(tmpdir(), 'agi-cli', 'bun-pty', filename);
89
- const fromEmbedded = await readFromEmbedded(embeddedUrl, tmpPath);
90
- if (fromEmbedded) return fromEmbedded;
54
+ const platformLibs =
55
+ RUST_PTY_LIBS[process.platform as keyof typeof RUST_PTY_LIBS];
56
+ const embeddedPath =
57
+ platformLibs?.[process.arch === 'arm64' ? 'arm64' : 'x64'];
58
+
59
+ if (embeddedPath) {
60
+ const targetDir = join(getGlobalConfigDir(), 'runtime', 'bun-pty');
61
+ mkdirSync(targetDir, { recursive: true });
62
+ const targetPath = join(targetDir, filename);
63
+ const source = Bun.file(embeddedPath);
64
+ await Bun.write(targetPath, source);
65
+ process.env.BUN_PTY_LIB = targetPath;
66
+ return targetPath;
91
67
  }
92
68
 
93
69
  return null;
@@ -0,0 +1,30 @@
1
+ import darwinArm64 from 'bun-pty/rust-pty/target/release/librust_pty_arm64.dylib' with {
2
+ type: 'file',
3
+ };
4
+ import darwinX64 from 'bun-pty/rust-pty/target/release/librust_pty.dylib' with {
5
+ type: 'file',
6
+ };
7
+ import linuxArm64 from 'bun-pty/rust-pty/target/release/librust_pty_arm64.so' with {
8
+ type: 'file',
9
+ };
10
+ import linuxX64 from 'bun-pty/rust-pty/target/release/librust_pty.so' with {
11
+ type: 'file',
12
+ };
13
+ import windowsDll from 'bun-pty/rust-pty/target/release/rust_pty.dll' with {
14
+ type: 'file',
15
+ };
16
+
17
+ export const RUST_PTY_LIBS = {
18
+ darwin: {
19
+ arm64: darwinArm64,
20
+ x64: darwinX64,
21
+ },
22
+ linux: {
23
+ arm64: linuxArm64,
24
+ x64: linuxX64,
25
+ },
26
+ win32: {
27
+ arm64: windowsDll,
28
+ x64: windowsDll,
29
+ },
30
+ } as const;