recursive-llm-ts 2.0.3 → 2.0.5

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/README.md CHANGED
@@ -14,14 +14,20 @@ npm install recursive-llm-ts
14
14
  - **Python 3.9+** - Required for the underlying recursive-llm Python package
15
15
  - **pip** - Python package manager
16
16
 
17
- **Python dependencies are automatically installed** via the `postinstall` script when you `npm install`. The script will run `pip install -e` on the bundled Python package, installing `litellm`, `RestrictedPython`, and other dependencies.
17
+ ### Python Dependencies
18
+
19
+ Python dependencies are **automatically installed** via the `postinstall` script when you run `npm install` or `bun install`. The script will install `litellm`, `RestrictedPython`, and other required Python packages.
20
+
21
+ If automatic installation fails (e.g., pip not in PATH), you can manually install:
18
22
 
19
- #### For Bun Users
20
- If using Bun, also install `bunpy`:
21
23
  ```bash
22
- bun add bunpy
24
+ cd node_modules/recursive-llm-ts/recursive-llm
25
+ pip install -e .
23
26
  ```
24
27
 
28
+ #### For Bun Users
29
+ Bunpy is included as a dependency, so no additional installation needed.
30
+
25
31
  The package will automatically detect your runtime and use the appropriate Python bridge:
26
32
  - **Node.js** → uses `pythonia` (included)
27
33
  - **Bun** → uses `bunpy` (peer dependency)
@@ -74,31 +74,20 @@ class BunpyBridge {
74
74
  throw new Error('bunpy is not installed. Install it with: bun add bunpy\n' +
75
75
  'Note: bunpy only works with Bun runtime, not Node.js');
76
76
  }
77
- // Import sys and subprocess modules
77
+ // Import sys module to add path
78
78
  const sys = this.python.import('sys');
79
- const subprocess = this.python.import('subprocess');
80
- const os = this.python.import('os');
81
- // Install Python dependencies if not already installed
82
79
  const pythonPackagePath = path.join(__dirname, '..', 'recursive-llm');
83
- try {
84
- // Check if litellm is importable
85
- try {
86
- this.python.import('litellm');
87
- }
88
- catch (_a) {
89
- // Install dependencies using pip
90
- const result = subprocess.run([sys.executable, '-m', 'pip', 'install', '-e', pythonPackagePath], { capture_output: true, text: true, check: true });
91
- }
92
- }
93
- catch (installError) {
94
- console.warn('[recursive-llm-ts] Failed to auto-install Python dependencies:', installError);
95
- console.warn('[recursive-llm-ts] Please manually run: pip install -e', pythonPackagePath);
96
- }
97
- // Add Python source path
98
80
  const pythonSrcPath = path.join(pythonPackagePath, 'src');
99
81
  sys.path.insert(0, pythonSrcPath);
100
82
  // Import the rlm module
101
- this.rlmModule = this.python.import('rlm');
83
+ try {
84
+ this.rlmModule = this.python.import('rlm');
85
+ }
86
+ catch (error) {
87
+ throw new Error('Failed to import rlm module. Python dependencies may not be installed.\n' +
88
+ `Run: pip install -e ${pythonPackagePath}\n` +
89
+ `Original error: ${error.message || error}`);
90
+ }
102
91
  });
103
92
  }
104
93
  completion(model_1, query_1, context_1) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "recursive-llm-ts",
3
- "version": "2.0.3",
3
+ "version": "2.0.5",
4
4
  "description": "TypeScript bridge for recursive-llm: Recursive Language Models for unbounded context processing",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -8,24 +8,37 @@ const pyprojectPath = path.join(pythonPackagePath, 'pyproject.toml');
8
8
 
9
9
  // Check if pyproject.toml exists
10
10
  if (!fs.existsSync(pyprojectPath)) {
11
- console.error('Error: pyproject.toml not found at', pyprojectPath);
12
- process.exit(1);
11
+ console.warn('[recursive-llm-ts] Warning: pyproject.toml not found at', pyprojectPath);
12
+ console.warn('[recursive-llm-ts] Python dependencies will need to be installed manually');
13
+ process.exit(0); // Don't fail the install
13
14
  }
14
15
 
15
- console.log('Installing Python dependencies for recursive-llm...');
16
- console.log('Note: Python source is vendored with patches pre-applied.');
16
+ console.log('[recursive-llm-ts] Installing Python dependencies...');
17
17
 
18
18
  try {
19
+ // Check if pip is available
20
+ try {
21
+ execSync('pip --version', { stdio: 'pipe' });
22
+ } catch {
23
+ // Try pip3
24
+ execSync('pip3 --version', { stdio: 'pipe' });
25
+ }
26
+
19
27
  // Install the Python package in editable mode
20
- execSync(`pip install -e "${pythonPackagePath}"`, {
28
+ const pipCommand = process.platform === 'win32'
29
+ ? `pip install -e "${pythonPackagePath}"`
30
+ : `pip install -e "${pythonPackagePath}" || pip3 install -e "${pythonPackagePath}"`;
31
+
32
+ execSync(pipCommand, {
21
33
  stdio: 'inherit',
22
34
  cwd: pythonPackagePath
23
35
  });
24
- console.log('✓ Python dependencies installed successfully');
36
+ console.log('[recursive-llm-ts] ✓ Python dependencies installed successfully');
25
37
  } catch (error) {
26
- console.error('Failed to install Python dependencies.');
27
- console.error('Please ensure Python 3.9+ and pip are installed.');
28
- console.error('You can manually install by running:');
29
- console.error(` cd ${pythonPackagePath} && pip install -e .`);
30
- process.exit(1);
38
+ console.warn('[recursive-llm-ts] Warning: Failed to auto-install Python dependencies');
39
+ console.warn('[recursive-llm-ts] This is not critical - you can install them manually:');
40
+ console.warn(`[recursive-llm-ts] cd node_modules/recursive-llm-ts/recursive-llm && pip install -e .`);
41
+ console.warn('[recursive-llm-ts] Or ensure Python 3.9+ and pip are in your PATH');
42
+ // Don't fail the npm install - exit with 0
43
+ process.exit(0);
31
44
  }