recursive-llm-ts 2.0.12 → 3.0.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.
@@ -1,37 +0,0 @@
1
- """Type definitions for RLM."""
2
-
3
- from typing import TypedDict, Optional, Any, Callable, Awaitable
4
-
5
-
6
- class Message(TypedDict):
7
- """LLM message format."""
8
- role: str
9
- content: str
10
-
11
-
12
- class RLMConfig(TypedDict, total=False):
13
- """Configuration for RLM instance."""
14
- model: str
15
- recursive_model: Optional[str]
16
- api_base: Optional[str]
17
- api_key: Optional[str]
18
- max_depth: int
19
- max_iterations: int
20
- temperature: float
21
- timeout: int
22
-
23
-
24
- class REPLEnvironment(TypedDict, total=False):
25
- """REPL execution environment."""
26
- context: str
27
- query: str
28
- recursive_llm: Callable[[str, str], Awaitable[str]]
29
- re: Any # re module
30
-
31
-
32
- class CompletionResult(TypedDict):
33
- """Result from RLM completion."""
34
- answer: str
35
- iterations: int
36
- depth: int
37
- llm_calls: int
@@ -1,101 +0,0 @@
1
- #!/usr/bin/env node
2
- const { execSync, execFileSync } = require('child_process');
3
- const path = require('path');
4
- const fs = require('fs');
5
-
6
- const pythonPackagePath = path.join(__dirname, '..', 'recursive-llm');
7
- const pyprojectPath = path.join(pythonPackagePath, 'pyproject.toml');
8
- const pythonDepsPath = path.join(pythonPackagePath, '.pydeps');
9
-
10
- // Check if pyproject.toml exists
11
- if (!fs.existsSync(pyprojectPath)) {
12
- console.warn('[recursive-llm-ts] Warning: pyproject.toml not found at', pyprojectPath);
13
- console.warn('[recursive-llm-ts] Python dependencies will need to be installed manually');
14
- process.exit(0); // Don't fail the install
15
- }
16
-
17
- console.log('[recursive-llm-ts] Installing Python dependencies locally...');
18
-
19
- const dependencySpecifiers = (() => {
20
- try {
21
- const pyproject = fs.readFileSync(pyprojectPath, 'utf8');
22
- const depsBlock = pyproject.match(/dependencies\s*=\s*\[[\s\S]*?\]/);
23
- if (!depsBlock) return [];
24
- return Array.from(depsBlock[0].matchAll(/"([^"]+)"/g), (match) => match[1]);
25
- } catch {
26
- return [];
27
- }
28
- })();
29
-
30
- const installArgs = dependencySpecifiers.length > 0
31
- ? ['-m', 'pip', 'install', '--upgrade', '--target', pythonDepsPath, ...dependencySpecifiers]
32
- : ['-m', 'pip', 'install', '-e', pythonPackagePath];
33
- const dependencyArgs = dependencySpecifiers.map((dep) => `"${dep}"`).join(' ');
34
-
35
- try {
36
-
37
- const pythonCandidates = [];
38
- if (process.env.PYTHON) {
39
- pythonCandidates.push({ command: process.env.PYTHON, args: [] });
40
- }
41
- if (process.platform === 'win32') {
42
- pythonCandidates.push({ command: 'py', args: ['-3'] });
43
- pythonCandidates.push({ command: 'python', args: [] });
44
- pythonCandidates.push({ command: 'python3', args: [] });
45
- } else {
46
- pythonCandidates.push({ command: 'python3', args: [] });
47
- pythonCandidates.push({ command: 'python', args: [] });
48
- }
49
-
50
- let pythonCmd = null;
51
- for (const candidate of pythonCandidates) {
52
- try {
53
- execFileSync(candidate.command, [...candidate.args, '--version'], { stdio: 'pipe' });
54
- pythonCmd = candidate;
55
- break;
56
- } catch {
57
- // Try next candidate
58
- }
59
- }
60
-
61
- if (pythonCmd) {
62
- fs.mkdirSync(pythonDepsPath, { recursive: true });
63
- execFileSync(
64
- pythonCmd.command,
65
- [...pythonCmd.args, ...installArgs],
66
- { stdio: 'inherit', cwd: pythonPackagePath }
67
- );
68
- } else {
69
- // Fall back to pip/pip3 if a Python executable wasn't found
70
- try {
71
- execSync('pip --version', { stdio: 'pipe' });
72
- } catch {
73
- execSync('pip3 --version', { stdio: 'pipe' });
74
- }
75
- const pipCommand = dependencySpecifiers.length > 0
76
- ? `pip install --upgrade --target "${pythonDepsPath}" ${dependencySpecifiers.map((dep) => `"${dep}"`).join(' ')}`
77
- : process.platform === 'win32'
78
- ? `pip install -e "${pythonPackagePath}"`
79
- : `pip install -e "${pythonPackagePath}" || pip3 install -e "${pythonPackagePath}"`;
80
- fs.mkdirSync(pythonDepsPath, { recursive: true });
81
- execSync(pipCommand, {
82
- stdio: 'inherit',
83
- cwd: pythonPackagePath
84
- });
85
- }
86
- console.log('[recursive-llm-ts] ✓ Python dependencies installed successfully');
87
- } catch (error) {
88
- console.warn('[recursive-llm-ts] Warning: Failed to auto-install Python dependencies');
89
- console.warn('[recursive-llm-ts] This is not critical - you can install them manually:');
90
- if (dependencySpecifiers.length > 0) {
91
- console.warn(
92
- `[recursive-llm-ts] cd node_modules/recursive-llm-ts/recursive-llm && ` +
93
- `python -m pip install --upgrade --target .pydeps ${dependencyArgs}`
94
- );
95
- } else {
96
- console.warn(`[recursive-llm-ts] cd node_modules/recursive-llm-ts/recursive-llm && python -m pip install -e .`);
97
- }
98
- console.warn('[recursive-llm-ts] Or ensure Python 3.9+ and pip are in your PATH');
99
- // Don't fail the npm install - exit with 0
100
- process.exit(0);
101
- }