recursive-llm-ts 5.2.6 → 5.2.7

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.
@@ -58,18 +58,61 @@ const PLATFORM_PACKAGES = {
58
58
  'linux-arm64': '@recursive-llm/linux-arm64',
59
59
  'win32-x64': '@recursive-llm/win32-x64',
60
60
  };
61
+ /**
62
+ * Walk up the directory tree from PKG_ROOT_DIR, looking for the platform
63
+ * package binary inside node_modules directories. This handles pnpm's strict
64
+ * isolation where require.resolve() cannot find optional dependencies.
65
+ */
66
+ function findBinaryInNodeModules(pkgName) {
67
+ let dir = pkg_dir_1.PKG_ROOT_DIR;
68
+ const seenDirs = new Set();
69
+ while (dir && !seenDirs.has(dir)) {
70
+ seenDirs.add(dir);
71
+ // Standard node_modules layout (npm, yarn)
72
+ const candidate = path.join(dir, 'node_modules', pkgName, 'bin', DEFAULT_GO_BINARY);
73
+ if (fs.existsSync(candidate))
74
+ return true;
75
+ // pnpm .pnpm directory
76
+ const pnpmDir = path.join(dir, 'node_modules', '.pnpm');
77
+ if (fs.existsSync(pnpmDir)) {
78
+ const pnpmName = pkgName.replace('/', '+');
79
+ try {
80
+ const entries = fs.readdirSync(pnpmDir);
81
+ for (const entry of entries) {
82
+ if (entry.startsWith(pnpmName + '@')) {
83
+ const pnpmCandidate = path.join(pnpmDir, entry, 'node_modules', pkgName, 'bin', DEFAULT_GO_BINARY);
84
+ if (fs.existsSync(pnpmCandidate))
85
+ return true;
86
+ }
87
+ }
88
+ }
89
+ catch (_a) {
90
+ // Permission error or similar — skip
91
+ }
92
+ }
93
+ const parent = path.dirname(dir);
94
+ if (parent === dir)
95
+ break;
96
+ dir = parent;
97
+ }
98
+ return false;
99
+ }
61
100
  function isPlatformBinaryAvailable() {
62
101
  const key = `${process.platform}-${process.arch}`;
63
102
  const pkgName = PLATFORM_PACKAGES[key];
64
103
  if (!pkgName)
65
104
  return false;
105
+ // 1. Try require.resolve (works with npm, yarn, and non-strict pnpm)
66
106
  try {
67
107
  const pkgDir = path.dirname(require.resolve(`${pkgName}/package.json`));
68
- return fs.existsSync(path.join(pkgDir, 'bin', DEFAULT_GO_BINARY));
108
+ if (fs.existsSync(path.join(pkgDir, 'bin', DEFAULT_GO_BINARY)))
109
+ return true;
69
110
  }
70
111
  catch (_a) {
71
- return false;
112
+ // Fall through to filesystem search
72
113
  }
114
+ // 2. Walk up directory tree looking in node_modules (handles pnpm strict isolation)
115
+ return findBinaryInNodeModules(pkgName);
73
116
  }
74
117
  function isGoBinaryAvailable() {
75
118
  const envPath = process.env.RLM_GO_BINARY;
@@ -67,6 +67,48 @@ const PLATFORM_PACKAGES = {
67
67
  'linux-arm64': '@recursive-llm/linux-arm64',
68
68
  'win32-x64': '@recursive-llm/win32-x64',
69
69
  };
70
+ /**
71
+ * Walk up the directory tree from a starting point, looking for the platform
72
+ * package binary inside node_modules directories. This handles pnpm's strict
73
+ * isolation where require.resolve() cannot find optional dependencies.
74
+ */
75
+ function findBinaryInNodeModules(pkgName) {
76
+ let dir = pkg_dir_1.PKG_ROOT_DIR;
77
+ const seenDirs = new Set();
78
+ while (dir && !seenDirs.has(dir)) {
79
+ seenDirs.add(dir);
80
+ // Standard node_modules layout (npm, yarn)
81
+ const candidate = path.join(dir, 'node_modules', pkgName, 'bin', DEFAULT_BINARY_NAME);
82
+ if (fs.existsSync(candidate))
83
+ return candidate;
84
+ // pnpm hoisted node_modules (the package may be hoisted even under pnpm)
85
+ // Also check .pnpm directory where pnpm stores the actual package contents
86
+ const pnpmDir = path.join(dir, 'node_modules', '.pnpm');
87
+ if (fs.existsSync(pnpmDir)) {
88
+ // pnpm stores packages as: .pnpm/<name>@<version>/node_modules/<name>/
89
+ // where scoped packages use + instead of / in the directory name
90
+ const pnpmName = pkgName.replace('/', '+');
91
+ try {
92
+ const entries = fs.readdirSync(pnpmDir);
93
+ for (const entry of entries) {
94
+ if (entry.startsWith(pnpmName + '@')) {
95
+ const pnpmCandidate = path.join(pnpmDir, entry, 'node_modules', pkgName, 'bin', DEFAULT_BINARY_NAME);
96
+ if (fs.existsSync(pnpmCandidate))
97
+ return pnpmCandidate;
98
+ }
99
+ }
100
+ }
101
+ catch (_a) {
102
+ // Permission error or similar — skip
103
+ }
104
+ }
105
+ const parent = path.dirname(dir);
106
+ if (parent === dir)
107
+ break;
108
+ dir = parent;
109
+ }
110
+ return null;
111
+ }
70
112
  function resolvePlatformBinary() {
71
113
  const platform = process.platform;
72
114
  const arch = process.arch;
@@ -74,17 +116,18 @@ function resolvePlatformBinary() {
74
116
  const pkgName = PLATFORM_PACKAGES[key];
75
117
  if (!pkgName)
76
118
  return null;
119
+ // 1. Try require.resolve (works with npm, yarn, and non-strict pnpm)
77
120
  try {
78
- // require.resolve works in both CJS and ESM (via createRequire)
79
121
  const pkgDir = path.dirname(require.resolve(`${pkgName}/package.json`));
80
122
  const binPath = path.join(pkgDir, 'bin', DEFAULT_BINARY_NAME);
81
123
  if (fs.existsSync(binPath))
82
124
  return binPath;
83
125
  }
84
126
  catch (_a) {
85
- // Package not installed — fall through
127
+ // Package not resolvable via require — fall through to filesystem search
86
128
  }
87
- return null;
129
+ // 2. Walk up directory tree looking in node_modules (handles pnpm strict isolation)
130
+ return findBinaryInNodeModules(pkgName);
88
131
  }
89
132
  function resolveBinaryPath(rlmConfig) {
90
133
  const configuredPath = rlmConfig.go_binary_path || process.env.RLM_GO_BINARY;
@@ -22,18 +22,61 @@ const PLATFORM_PACKAGES = {
22
22
  'linux-arm64': '@recursive-llm/linux-arm64',
23
23
  'win32-x64': '@recursive-llm/win32-x64',
24
24
  };
25
+ /**
26
+ * Walk up the directory tree from PKG_ROOT_DIR, looking for the platform
27
+ * package binary inside node_modules directories. This handles pnpm's strict
28
+ * isolation where require.resolve() cannot find optional dependencies.
29
+ */
30
+ function findBinaryInNodeModules(pkgName) {
31
+ let dir = PKG_ROOT_DIR;
32
+ const seenDirs = new Set();
33
+ while (dir && !seenDirs.has(dir)) {
34
+ seenDirs.add(dir);
35
+ // Standard node_modules layout (npm, yarn)
36
+ const candidate = path.join(dir, 'node_modules', pkgName, 'bin', DEFAULT_GO_BINARY);
37
+ if (fs.existsSync(candidate))
38
+ return true;
39
+ // pnpm .pnpm directory
40
+ const pnpmDir = path.join(dir, 'node_modules', '.pnpm');
41
+ if (fs.existsSync(pnpmDir)) {
42
+ const pnpmName = pkgName.replace('/', '+');
43
+ try {
44
+ const entries = fs.readdirSync(pnpmDir);
45
+ for (const entry of entries) {
46
+ if (entry.startsWith(pnpmName + '@')) {
47
+ const pnpmCandidate = path.join(pnpmDir, entry, 'node_modules', pkgName, 'bin', DEFAULT_GO_BINARY);
48
+ if (fs.existsSync(pnpmCandidate))
49
+ return true;
50
+ }
51
+ }
52
+ }
53
+ catch (_a) {
54
+ // Permission error or similar — skip
55
+ }
56
+ }
57
+ const parent = path.dirname(dir);
58
+ if (parent === dir)
59
+ break;
60
+ dir = parent;
61
+ }
62
+ return false;
63
+ }
25
64
  function isPlatformBinaryAvailable() {
26
65
  const key = `${process.platform}-${process.arch}`;
27
66
  const pkgName = PLATFORM_PACKAGES[key];
28
67
  if (!pkgName)
29
68
  return false;
69
+ // 1. Try require.resolve (works with npm, yarn, and non-strict pnpm)
30
70
  try {
31
71
  const pkgDir = path.dirname(require.resolve(`${pkgName}/package.json`));
32
- return fs.existsSync(path.join(pkgDir, 'bin', DEFAULT_GO_BINARY));
72
+ if (fs.existsSync(path.join(pkgDir, 'bin', DEFAULT_GO_BINARY)))
73
+ return true;
33
74
  }
34
75
  catch (_a) {
35
- return false;
76
+ // Fall through to filesystem search
36
77
  }
78
+ // 2. Walk up directory tree looking in node_modules (handles pnpm strict isolation)
79
+ return findBinaryInNodeModules(pkgName);
37
80
  }
38
81
  function isGoBinaryAvailable() {
39
82
  const envPath = process.env.RLM_GO_BINARY;
@@ -31,6 +31,48 @@ const PLATFORM_PACKAGES = {
31
31
  'linux-arm64': '@recursive-llm/linux-arm64',
32
32
  'win32-x64': '@recursive-llm/win32-x64',
33
33
  };
34
+ /**
35
+ * Walk up the directory tree from a starting point, looking for the platform
36
+ * package binary inside node_modules directories. This handles pnpm's strict
37
+ * isolation where require.resolve() cannot find optional dependencies.
38
+ */
39
+ function findBinaryInNodeModules(pkgName) {
40
+ let dir = PKG_ROOT_DIR;
41
+ const seenDirs = new Set();
42
+ while (dir && !seenDirs.has(dir)) {
43
+ seenDirs.add(dir);
44
+ // Standard node_modules layout (npm, yarn)
45
+ const candidate = path.join(dir, 'node_modules', pkgName, 'bin', DEFAULT_BINARY_NAME);
46
+ if (fs.existsSync(candidate))
47
+ return candidate;
48
+ // pnpm hoisted node_modules (the package may be hoisted even under pnpm)
49
+ // Also check .pnpm directory where pnpm stores the actual package contents
50
+ const pnpmDir = path.join(dir, 'node_modules', '.pnpm');
51
+ if (fs.existsSync(pnpmDir)) {
52
+ // pnpm stores packages as: .pnpm/<name>@<version>/node_modules/<name>/
53
+ // where scoped packages use + instead of / in the directory name
54
+ const pnpmName = pkgName.replace('/', '+');
55
+ try {
56
+ const entries = fs.readdirSync(pnpmDir);
57
+ for (const entry of entries) {
58
+ if (entry.startsWith(pnpmName + '@')) {
59
+ const pnpmCandidate = path.join(pnpmDir, entry, 'node_modules', pkgName, 'bin', DEFAULT_BINARY_NAME);
60
+ if (fs.existsSync(pnpmCandidate))
61
+ return pnpmCandidate;
62
+ }
63
+ }
64
+ }
65
+ catch (_a) {
66
+ // Permission error or similar — skip
67
+ }
68
+ }
69
+ const parent = path.dirname(dir);
70
+ if (parent === dir)
71
+ break;
72
+ dir = parent;
73
+ }
74
+ return null;
75
+ }
34
76
  function resolvePlatformBinary() {
35
77
  const platform = process.platform;
36
78
  const arch = process.arch;
@@ -38,17 +80,18 @@ function resolvePlatformBinary() {
38
80
  const pkgName = PLATFORM_PACKAGES[key];
39
81
  if (!pkgName)
40
82
  return null;
83
+ // 1. Try require.resolve (works with npm, yarn, and non-strict pnpm)
41
84
  try {
42
- // require.resolve works in both CJS and ESM (via createRequire)
43
85
  const pkgDir = path.dirname(require.resolve(`${pkgName}/package.json`));
44
86
  const binPath = path.join(pkgDir, 'bin', DEFAULT_BINARY_NAME);
45
87
  if (fs.existsSync(binPath))
46
88
  return binPath;
47
89
  }
48
90
  catch (_a) {
49
- // Package not installed — fall through
91
+ // Package not resolvable via require — fall through to filesystem search
50
92
  }
51
- return null;
93
+ // 2. Walk up directory tree looking in node_modules (handles pnpm strict isolation)
94
+ return findBinaryInNodeModules(pkgName);
52
95
  }
53
96
  function resolveBinaryPath(rlmConfig) {
54
97
  const configuredPath = rlmConfig.go_binary_path || process.env.RLM_GO_BINARY;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "recursive-llm-ts",
3
- "version": "5.2.6",
3
+ "version": "5.2.7",
4
4
  "description": "TypeScript bridge for recursive-llm: Recursive Language Models for unbounded context processing with structured outputs",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -88,10 +88,10 @@
88
88
  }
89
89
  },
90
90
  "optionalDependencies": {
91
- "@recursive-llm/darwin-arm64": "5.2.6",
92
- "@recursive-llm/darwin-x64": "5.2.6",
93
- "@recursive-llm/linux-x64": "5.2.6",
94
- "@recursive-llm/linux-arm64": "5.2.6",
95
- "@recursive-llm/win32-x64": "5.2.6"
91
+ "@recursive-llm/darwin-arm64": "5.2.7",
92
+ "@recursive-llm/darwin-x64": "5.2.7",
93
+ "@recursive-llm/linux-x64": "5.2.7",
94
+ "@recursive-llm/linux-arm64": "5.2.7",
95
+ "@recursive-llm/win32-x64": "5.2.7"
96
96
  }
97
97
  }
@@ -21,7 +21,49 @@ const PLATFORM_PACKAGES = {
21
21
  const platformKey = `${process.platform}-${process.arch}`;
22
22
  const platformPkg = PLATFORM_PACKAGES[platformKey];
23
23
 
24
+ /**
25
+ * Walk up the directory tree from repoRoot looking for the platform package
26
+ * binary inside node_modules directories. Handles pnpm's strict isolation
27
+ * where require.resolve() cannot find optional dependencies.
28
+ */
29
+ function findBinaryInNodeModules(pkgName) {
30
+ let dir = repoRoot;
31
+ const seenDirs = new Set();
32
+ while (dir && !seenDirs.has(dir)) {
33
+ seenDirs.add(dir);
34
+
35
+ // Standard node_modules layout (npm, yarn)
36
+ const candidate = path.join(dir, 'node_modules', pkgName, 'bin', binaryName);
37
+ if (fs.existsSync(candidate)) return candidate;
38
+
39
+ // pnpm .pnpm directory
40
+ const pnpmDir = path.join(dir, 'node_modules', '.pnpm');
41
+ if (fs.existsSync(pnpmDir)) {
42
+ const pnpmName = pkgName.replace('/', '+');
43
+ try {
44
+ const entries = fs.readdirSync(pnpmDir);
45
+ for (const entry of entries) {
46
+ if (entry.startsWith(pnpmName + '@')) {
47
+ const pnpmCandidate = path.join(
48
+ pnpmDir, entry, 'node_modules', pkgName, 'bin', binaryName
49
+ );
50
+ if (fs.existsSync(pnpmCandidate)) return pnpmCandidate;
51
+ }
52
+ }
53
+ } catch {
54
+ // Permission error or similar — skip
55
+ }
56
+ }
57
+
58
+ const parent = path.dirname(dir);
59
+ if (parent === dir) break;
60
+ dir = parent;
61
+ }
62
+ return null;
63
+ }
64
+
24
65
  if (platformPkg) {
66
+ // 1. Try require.resolve (works with npm, yarn, and non-strict pnpm)
25
67
  try {
26
68
  const pkgDir = path.dirname(require.resolve(`${platformPkg}/package.json`));
27
69
  const platformBinary = path.join(pkgDir, 'bin', binaryName);
@@ -30,7 +72,14 @@ if (platformPkg) {
30
72
  process.exit(0);
31
73
  }
32
74
  } catch {
33
- // Package not installedcontinue to local build
75
+ // Package not resolvable via require fall through to filesystem search
76
+ }
77
+
78
+ // 2. Walk up directory tree looking in node_modules (handles pnpm strict isolation)
79
+ const found = findBinaryInNodeModules(platformPkg);
80
+ if (found) {
81
+ console.log(`[recursive-llm-ts] ✓ Pre-built binary found at ${found}`);
82
+ process.exit(0);
34
83
  }
35
84
  }
36
85