@agi-cli/sdk 0.1.158 → 0.1.159

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.158",
3
+ "version": "0.1.159",
4
4
  "description": "AI agent SDK for building intelligent assistants - tree-shakable and comprehensive",
5
5
  "author": "nitishxyz",
6
6
  "license": "MIT",
@@ -1,11 +1,13 @@
1
1
  import { join } from 'node:path';
2
2
  import { promises as fs } from 'node:fs';
3
- import { spawn } from 'node:child_process';
3
+ import { spawn, execSync } from 'node:child_process';
4
+ import { homedir } from 'node:os';
4
5
 
5
6
  const AGI_BIN_DIR_NAME = 'bin';
6
7
 
7
8
  let cachedBinDir: string | null = null;
8
9
  const resolvedPaths = new Map<string, string>();
10
+ let cachedLoginPath: string | null = null;
9
11
 
10
12
  function getConfigHome(): string {
11
13
  const cfgHome = process.env.XDG_CONFIG_HOME;
@@ -188,10 +190,61 @@ export function clearBinaryCache(): void {
188
190
  resolvedPaths.clear();
189
191
  }
190
192
 
193
+ function getLoginShellPath(): string | null {
194
+ if (cachedLoginPath !== null) return cachedLoginPath;
195
+
196
+ if (process.platform === 'win32') {
197
+ cachedLoginPath = process.env.PATH || '';
198
+ return cachedLoginPath;
199
+ }
200
+
201
+ const home = process.env.HOME || homedir();
202
+ const shellCandidates = [
203
+ process.env.SHELL,
204
+ '/bin/zsh',
205
+ '/bin/bash',
206
+ '/bin/sh',
207
+ ].filter(Boolean) as string[];
208
+
209
+ for (const shell of shellCandidates) {
210
+ try {
211
+ const result = execSync(`${shell} -ilc 'echo "___PATH___:$PATH"'`, {
212
+ timeout: 5000,
213
+ stdio: ['ignore', 'pipe', 'ignore'],
214
+ env: { HOME: home, USER: process.env.USER || '', SHELL: shell },
215
+ });
216
+ const output = result.toString();
217
+ const match = output.match(/___PATH___:(.*)/);
218
+ if (match?.[1]?.trim()) {
219
+ cachedLoginPath = match[1].trim();
220
+ return cachedLoginPath;
221
+ }
222
+ } catch {}
223
+ }
224
+
225
+ cachedLoginPath = null;
226
+ return null;
227
+ }
228
+
191
229
  export function getAugmentedPath(): string {
230
+ const sep = process.platform === 'win32' ? ';' : ':';
192
231
  const binDir = getAgiBinDir();
193
232
  const current = process.env.PATH || '';
194
- const commonPaths = ['/opt/homebrew/bin', '/usr/local/bin'];
195
- const parts = [binDir, ...commonPaths, current];
196
- return parts.join(process.platform === 'win32' ? ';' : ':');
233
+ const loginPath = getLoginShellPath();
234
+
235
+ const seen = new Set<string>();
236
+ const parts: string[] = [];
237
+
238
+ for (const p of [
239
+ binDir,
240
+ ...(loginPath ? loginPath.split(sep) : []),
241
+ ...current.split(sep),
242
+ ]) {
243
+ if (p && !seen.has(p)) {
244
+ seen.add(p);
245
+ parts.push(p);
246
+ }
247
+ }
248
+
249
+ return parts.join(sep);
197
250
  }