@agentuity/cli 0.1.33 → 0.1.34
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/dist/cmd/cloud/sandbox/exec.d.ts.map +1 -1
- package/dist/cmd/cloud/sandbox/exec.js +10 -35
- package/dist/cmd/cloud/sandbox/exec.js.map +1 -1
- package/dist/utils/installation-type.d.ts.map +1 -1
- package/dist/utils/installation-type.js +54 -16
- package/dist/utils/installation-type.js.map +1 -1
- package/package.json +6 -6
- package/src/cmd/cloud/sandbox/exec.ts +10 -41
- package/src/utils/installation-type.ts +55 -16
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exec.d.ts","sourceRoot":"","sources":["../../../../src/cmd/cloud/sandbox/exec.ts"],"names":[],"mappings":"AAoBA,eAAO,MAAM,cAAc,
|
|
1
|
+
{"version":3,"file":"exec.d.ts","sourceRoot":"","sources":["../../../../src/cmd/cloud/sandbox/exec.ts"],"names":[],"mappings":"AAoBA,eAAO,MAAM,cAAc,sCAmJzB,CAAC;AAwDH,eAAe,cAAc,CAAC"}
|
|
@@ -5,8 +5,8 @@ import * as tui from '../../../tui';
|
|
|
5
5
|
import { getSandboxRegion, createSandboxClient } from './util';
|
|
6
6
|
import { getCommand } from '../../../command-prefix';
|
|
7
7
|
import { sandboxExecute, executionGet, writeAndDrain } from '@agentuity/server';
|
|
8
|
-
|
|
9
|
-
const
|
|
8
|
+
// Server-side long-poll wait duration (max 5 minutes supported by server)
|
|
9
|
+
const EXECUTION_WAIT_DURATION = '5m';
|
|
10
10
|
const SandboxExecResponseSchema = z.object({
|
|
11
11
|
executionId: z.string().describe('Unique execution identifier'),
|
|
12
12
|
status: z.string().describe('Execution status'),
|
|
@@ -95,36 +95,14 @@ export const execSubcommand = createCommand({
|
|
|
95
95
|
streamPromises.push(streamUrlToWritable(stderrStreamUrl, stderr, streamAbortController.signal, logger));
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
try {
|
|
107
|
-
const execInfo = await executionGet(client, {
|
|
108
|
-
executionId: execution.executionId,
|
|
109
|
-
orgId,
|
|
110
|
-
});
|
|
111
|
-
if (execInfo.status === 'completed' ||
|
|
112
|
-
execInfo.status === 'failed' ||
|
|
113
|
-
execInfo.status === 'timeout' ||
|
|
114
|
-
execInfo.status === 'cancelled') {
|
|
115
|
-
finalExecution = {
|
|
116
|
-
executionId: execInfo.executionId,
|
|
117
|
-
status: execInfo.status,
|
|
118
|
-
exitCode: execInfo.exitCode,
|
|
119
|
-
durationMs: execInfo.durationMs,
|
|
120
|
-
};
|
|
121
|
-
break;
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
catch {
|
|
125
|
-
continue;
|
|
126
|
-
}
|
|
127
|
-
}
|
|
98
|
+
// Use server-side long-polling to wait for execution completion
|
|
99
|
+
// This is more efficient than client-side polling and provides immediate
|
|
100
|
+
// error detection if the sandbox is terminated
|
|
101
|
+
const finalExecution = await executionGet(client, {
|
|
102
|
+
executionId: execution.executionId,
|
|
103
|
+
orgId,
|
|
104
|
+
wait: EXECUTION_WAIT_DURATION,
|
|
105
|
+
});
|
|
128
106
|
// Wait for all streams to reach EOF (Pulse blocks until true EOF)
|
|
129
107
|
await Promise.all(streamPromises);
|
|
130
108
|
// Ensure stdout is fully flushed before continuing
|
|
@@ -205,8 +183,5 @@ function createCaptureStream(onChunk) {
|
|
|
205
183
|
},
|
|
206
184
|
});
|
|
207
185
|
}
|
|
208
|
-
function sleep(ms) {
|
|
209
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
210
|
-
}
|
|
211
186
|
export default execSubcommand;
|
|
212
187
|
//# sourceMappingURL=exec.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exec.js","sourceRoot":"","sources":["../../../../src/cmd/cloud/sandbox/exec.ts"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gBAC3B,MAAM;YACP,CAAC;YAED,IAAI,KAAK,EAAE,CAAC;gBACX,MAAM,CAAC,KAAK,CAAC,wBAAwB,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;gBACrD,MAAM,aAAa,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;YACtC,CAAC;QACF,CAAC;IACF,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACd,IAAI,GAAG,YAAY,KAAK,IAAI,GAAG,CAAC,IAAI,KAAK,YAAY,EAAE,CAAC;YACvD,MAAM,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;YAC/B,OAAO;QACR,CAAC;QACD,MAAM,CAAC,KAAK,CAAC,kBAAkB,EAAE,GAAG,CAAC,CAAC;IACvC,CAAC;AACF,CAAC;AAED,SAAS,mBAAmB,CAAC,OAAgC;IAC5D,OAAO,IAAI,QAAQ,CAAC;QACnB,KAAK,CACJ,KAAsB,EACtB,SAAiB,EACjB,QAAwC;YAExC,MAAM,IAAI,GAAG,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;YACzE,OAAO,CAAC,IAAI,CAAC,CAAC;YACd,QAAQ,EAAE,CAAC;QACZ,CAAC;KACD,CAAC,CAAC;AACJ,CAAC;AAED,eAAe,cAAc,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"installation-type.d.ts","sourceRoot":"","sources":["../../src/utils/installation-type.ts"],"names":[],"mappings":"AAAA;;GAEG;
|
|
1
|
+
{"version":3,"file":"installation-type.d.ts","sourceRoot":"","sources":["../../src/utils/installation-type.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH,MAAM,MAAM,gBAAgB,GAAG,QAAQ,GAAG,OAAO,GAAG,QAAQ,CAAC;AAiB7D;;;;;;GAMG;AACH,wBAAgB,mBAAmB,IAAI,gBAAgB,CAqDtD;AAED;;GAEG;AACH,wBAAgB,eAAe,IAAI,OAAO,CAEzC;AAED;;GAEG;AACH,wBAAgB,cAAc,IAAI,OAAO,CAExC;AAED;;GAEG;AACH,wBAAgB,eAAe,IAAI,OAAO,CAEzC"}
|
|
@@ -1,7 +1,24 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Detects how the CLI was installed and is being run
|
|
3
3
|
*/
|
|
4
|
+
import fs from 'node:fs';
|
|
4
5
|
import os from 'node:os';
|
|
6
|
+
/**
|
|
7
|
+
* Resolve a path to its real path (following symlinks) and normalize to POSIX separators.
|
|
8
|
+
* Returns the original path if resolution fails.
|
|
9
|
+
*/
|
|
10
|
+
function resolveRealPath(path) {
|
|
11
|
+
if (!path)
|
|
12
|
+
return '';
|
|
13
|
+
try {
|
|
14
|
+
// fs.realpathSync resolves symlinks (e.g., /tmp -> /private/tmp on macOS)
|
|
15
|
+
return fs.realpathSync(path).replace(/\\/g, '/');
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
// If the path doesn't exist or can't be resolved, return normalized original
|
|
19
|
+
return path.replace(/\\/g, '/');
|
|
20
|
+
}
|
|
21
|
+
}
|
|
5
22
|
/**
|
|
6
23
|
* Determines the installation type based on how the CLI is being executed
|
|
7
24
|
*
|
|
@@ -10,29 +27,50 @@ import os from 'node:os';
|
|
|
10
27
|
* @returns 'source' - Running from source code (development)
|
|
11
28
|
*/
|
|
12
29
|
export function getInstallationType() {
|
|
13
|
-
//
|
|
30
|
+
// Bun.main already returns the resolved real path, just normalize separators
|
|
14
31
|
const mainPath = Bun.main.replace(/\\/g, '/');
|
|
15
|
-
//
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
//
|
|
19
|
-
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
//
|
|
23
|
-
//
|
|
24
|
-
|
|
25
|
-
|
|
32
|
+
// Get home directory reliably and resolve symlinks
|
|
33
|
+
// On macOS, os.homedir() returns /Users/xxx which is already real
|
|
34
|
+
const home = resolveRealPath(os.homedir() ?? process.env.HOME ?? process.env.USERPROFILE ?? '');
|
|
35
|
+
// Get bun install directory from BUN_INSTALL or default to ~/.bun
|
|
36
|
+
// Resolve symlinks to handle cases like BUN_INSTALL=/tmp/... on macOS where /tmp -> /private/tmp
|
|
37
|
+
const bunInstallRaw = process.env.BUN_INSTALL ?? (home ? `${home}/.bun` : '');
|
|
38
|
+
const bunInstall = resolveRealPath(bunInstallRaw);
|
|
39
|
+
// GLOBAL DETECTION: Check if running from bun's global install location
|
|
40
|
+
// When installed via `bun add -g`, the CLI lives at ~/.bun/node_modules/@agentuity/cli/
|
|
41
|
+
// or ~/.bun/install/global/node_modules/@agentuity/cli/
|
|
42
|
+
if (bunInstall) {
|
|
43
|
+
// Check for ~/.bun/node_modules/@agentuity/cli/ (common bun global layout)
|
|
44
|
+
if (mainPath.startsWith(`${bunInstall}/node_modules/@agentuity/cli/`)) {
|
|
45
|
+
return 'global';
|
|
46
|
+
}
|
|
47
|
+
// Check for ~/.bun/install/global/node_modules/@agentuity/cli/ (alternative layout)
|
|
48
|
+
if (mainPath.startsWith(`${bunInstall}/install/global/`)) {
|
|
49
|
+
return 'global';
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
// GLOBAL DETECTION: Check for legacy ~/.agentuity/ installation
|
|
53
|
+
// The install.sh script may install to ~/.agentuity/node_modules/@agentuity/cli/
|
|
54
|
+
// or create a shim at ~/.agentuity/bin/agentuity
|
|
55
|
+
if (home) {
|
|
56
|
+
const agentuityDir = resolveRealPath(`${home}/.agentuity`);
|
|
57
|
+
if (mainPath.startsWith(`${agentuityDir}/`)) {
|
|
58
|
+
return 'global';
|
|
59
|
+
}
|
|
26
60
|
}
|
|
27
|
-
//
|
|
28
|
-
|
|
61
|
+
// GLOBAL DETECTION: Fallback check for any path containing /.bun/ before node_modules
|
|
62
|
+
// This catches edge cases where BUN_INSTALL might not match the actual path
|
|
63
|
+
if (mainPath.includes('/.bun/') && mainPath.includes('/node_modules/@agentuity/cli/')) {
|
|
29
64
|
return 'global';
|
|
30
65
|
}
|
|
31
|
-
//
|
|
66
|
+
// LOCAL DETECTION: Running from a project's node_modules
|
|
67
|
+
// This is when someone runs `bunx agentuity` or has it as a project dependency
|
|
68
|
+
// At this point, we've ruled out global installs, so any node_modules path is local
|
|
32
69
|
if (mainPath.includes('/node_modules/@agentuity/cli/')) {
|
|
33
70
|
return 'local';
|
|
34
71
|
}
|
|
35
|
-
//
|
|
72
|
+
// SOURCE DETECTION: Running from source code (development)
|
|
73
|
+
// This is when running directly from the monorepo: packages/cli/bin/cli.ts
|
|
36
74
|
return 'source';
|
|
37
75
|
}
|
|
38
76
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"installation-type.js","sourceRoot":"","sources":["../../src/utils/installation-type.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,MAAM,SAAS,CAAC;AAIzB
|
|
1
|
+
{"version":3,"file":"installation-type.js","sourceRoot":"","sources":["../../src/utils/installation-type.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,MAAM,SAAS,CAAC;AAIzB;;;GAGG;AACH,SAAS,eAAe,CAAC,IAAY;IACpC,IAAI,CAAC,IAAI;QAAE,OAAO,EAAE,CAAC;IACrB,IAAI,CAAC;QACJ,0EAA0E;QAC1E,OAAO,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IAClD,CAAC;IAAC,MAAM,CAAC;QACR,6EAA6E;QAC7E,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IACjC,CAAC;AACF,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,mBAAmB;IAClC,6EAA6E;IAC7E,MAAM,QAAQ,GAAG,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IA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oF;IACpF,IAAI,QAAQ,CAAC,QAAQ,CAAC,+BAA+B,CAAC,EAAE,CAAC;QACxD,OAAO,OAAO,CAAC;IAChB,CAAC;IAED,2DAA2D;IAC3D,2EAA2E;IAC3E,OAAO,QAAQ,CAAC;AACjB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe;IAC9B,OAAO,mBAAmB,EAAE,KAAK,QAAQ,CAAC;AAC3C,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,cAAc;IAC7B,OAAO,mBAAmB,EAAE,KAAK,OAAO,CAAC;AAC1C,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe;IAC9B,OAAO,mBAAmB,EAAE,KAAK,QAAQ,CAAC;AAC3C,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentuity/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.34",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"author": "Agentuity employees and contributors",
|
|
6
6
|
"type": "module",
|
|
@@ -40,9 +40,9 @@
|
|
|
40
40
|
"prepublishOnly": "bun run clean && bun run build"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@agentuity/auth": "0.1.
|
|
44
|
-
"@agentuity/core": "0.1.
|
|
45
|
-
"@agentuity/server": "0.1.
|
|
43
|
+
"@agentuity/auth": "0.1.34",
|
|
44
|
+
"@agentuity/core": "0.1.34",
|
|
45
|
+
"@agentuity/server": "0.1.34",
|
|
46
46
|
"@datasert/cronjs-parser": "^1.4.0",
|
|
47
47
|
"@terascope/fetch-github-release": "^2.2.1",
|
|
48
48
|
"@vitejs/plugin-react": "^5.1.2",
|
|
@@ -60,10 +60,10 @@
|
|
|
60
60
|
"typescript": "^5.9.0",
|
|
61
61
|
"vite": "^7.2.7",
|
|
62
62
|
"zod": "^4.3.5",
|
|
63
|
-
"@agentuity/frontend": "0.1.
|
|
63
|
+
"@agentuity/frontend": "0.1.34"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
|
-
"@agentuity/test-utils": "0.1.
|
|
66
|
+
"@agentuity/test-utils": "0.1.34",
|
|
67
67
|
"@types/adm-zip": "^0.5.7",
|
|
68
68
|
"@types/bun": "latest",
|
|
69
69
|
"@types/tar-fs": "^2.0.4",
|
|
@@ -7,8 +7,8 @@ import { getCommand } from '../../../command-prefix';
|
|
|
7
7
|
import { sandboxExecute, executionGet, writeAndDrain } from '@agentuity/server';
|
|
8
8
|
import type { Logger } from '@agentuity/core';
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
const
|
|
10
|
+
// Server-side long-poll wait duration (max 5 minutes supported by server)
|
|
11
|
+
const EXECUTION_WAIT_DURATION = '5m';
|
|
12
12
|
|
|
13
13
|
const SandboxExecResponseSchema = z.object({
|
|
14
14
|
executionId: z.string().describe('Unique execution identifier'),
|
|
@@ -115,41 +115,14 @@ export const execSubcommand = createCommand({
|
|
|
115
115
|
}
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
await sleep(POLL_INTERVAL_MS);
|
|
127
|
-
attempts++;
|
|
128
|
-
|
|
129
|
-
try {
|
|
130
|
-
const execInfo = await executionGet(client, {
|
|
131
|
-
executionId: execution.executionId,
|
|
132
|
-
orgId,
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
if (
|
|
136
|
-
execInfo.status === 'completed' ||
|
|
137
|
-
execInfo.status === 'failed' ||
|
|
138
|
-
execInfo.status === 'timeout' ||
|
|
139
|
-
execInfo.status === 'cancelled'
|
|
140
|
-
) {
|
|
141
|
-
finalExecution = {
|
|
142
|
-
executionId: execInfo.executionId,
|
|
143
|
-
status: execInfo.status,
|
|
144
|
-
exitCode: execInfo.exitCode,
|
|
145
|
-
durationMs: execInfo.durationMs,
|
|
146
|
-
};
|
|
147
|
-
break;
|
|
148
|
-
}
|
|
149
|
-
} catch {
|
|
150
|
-
continue;
|
|
151
|
-
}
|
|
152
|
-
}
|
|
118
|
+
// Use server-side long-polling to wait for execution completion
|
|
119
|
+
// This is more efficient than client-side polling and provides immediate
|
|
120
|
+
// error detection if the sandbox is terminated
|
|
121
|
+
const finalExecution = await executionGet(client, {
|
|
122
|
+
executionId: execution.executionId,
|
|
123
|
+
orgId,
|
|
124
|
+
wait: EXECUTION_WAIT_DURATION,
|
|
125
|
+
});
|
|
153
126
|
|
|
154
127
|
// Wait for all streams to reach EOF (Pulse blocks until true EOF)
|
|
155
128
|
await Promise.all(streamPromises);
|
|
@@ -248,8 +221,4 @@ function createCaptureStream(onChunk: (chunk: string) => void): NodeJS.WritableS
|
|
|
248
221
|
});
|
|
249
222
|
}
|
|
250
223
|
|
|
251
|
-
function sleep(ms: number): Promise<void> {
|
|
252
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
253
|
-
}
|
|
254
|
-
|
|
255
224
|
export default execSubcommand;
|
|
@@ -2,10 +2,26 @@
|
|
|
2
2
|
* Detects how the CLI was installed and is being run
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
+
import fs from 'node:fs';
|
|
5
6
|
import os from 'node:os';
|
|
6
7
|
|
|
7
8
|
export type InstallationType = 'global' | 'local' | 'source';
|
|
8
9
|
|
|
10
|
+
/**
|
|
11
|
+
* Resolve a path to its real path (following symlinks) and normalize to POSIX separators.
|
|
12
|
+
* Returns the original path if resolution fails.
|
|
13
|
+
*/
|
|
14
|
+
function resolveRealPath(path: string): string {
|
|
15
|
+
if (!path) return '';
|
|
16
|
+
try {
|
|
17
|
+
// fs.realpathSync resolves symlinks (e.g., /tmp -> /private/tmp on macOS)
|
|
18
|
+
return fs.realpathSync(path).replace(/\\/g, '/');
|
|
19
|
+
} catch {
|
|
20
|
+
// If the path doesn't exist or can't be resolved, return normalized original
|
|
21
|
+
return path.replace(/\\/g, '/');
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
9
25
|
/**
|
|
10
26
|
* Determines the installation type based on how the CLI is being executed
|
|
11
27
|
*
|
|
@@ -14,34 +30,57 @@ export type InstallationType = 'global' | 'local' | 'source';
|
|
|
14
30
|
* @returns 'source' - Running from source code (development)
|
|
15
31
|
*/
|
|
16
32
|
export function getInstallationType(): InstallationType {
|
|
17
|
-
//
|
|
33
|
+
// Bun.main already returns the resolved real path, just normalize separators
|
|
18
34
|
const mainPath = Bun.main.replace(/\\/g, '/');
|
|
19
|
-
// Bun.argv[1] contains the original invocation path (before symlink resolution)
|
|
20
|
-
const invokedPath = (Bun.argv[1] ?? '').replace(/\\/g, '/');
|
|
21
35
|
|
|
22
|
-
// Get
|
|
23
|
-
//
|
|
24
|
-
const home = os.homedir() ?? process.env.HOME ?? process.env.USERPROFILE ?? '';
|
|
25
|
-
const bunInstall = (process.env.BUN_INSTALL ?? (home ? `${home}/.bun` : '')).replace(/\\/g, '/');
|
|
26
|
-
const globalBinDir = bunInstall ? `${bunInstall}/bin/` : '';
|
|
36
|
+
// Get home directory reliably and resolve symlinks
|
|
37
|
+
// On macOS, os.homedir() returns /Users/xxx which is already real
|
|
38
|
+
const home = resolveRealPath(os.homedir() ?? process.env.HOME ?? process.env.USERPROFILE ?? '');
|
|
27
39
|
|
|
28
|
-
//
|
|
29
|
-
//
|
|
30
|
-
|
|
31
|
-
|
|
40
|
+
// Get bun install directory from BUN_INSTALL or default to ~/.bun
|
|
41
|
+
// Resolve symlinks to handle cases like BUN_INSTALL=/tmp/... on macOS where /tmp -> /private/tmp
|
|
42
|
+
const bunInstallRaw = process.env.BUN_INSTALL ?? (home ? `${home}/.bun` : '');
|
|
43
|
+
const bunInstall = resolveRealPath(bunInstallRaw);
|
|
44
|
+
|
|
45
|
+
// GLOBAL DETECTION: Check if running from bun's global install location
|
|
46
|
+
// When installed via `bun add -g`, the CLI lives at ~/.bun/node_modules/@agentuity/cli/
|
|
47
|
+
// or ~/.bun/install/global/node_modules/@agentuity/cli/
|
|
48
|
+
if (bunInstall) {
|
|
49
|
+
// Check for ~/.bun/node_modules/@agentuity/cli/ (common bun global layout)
|
|
50
|
+
if (mainPath.startsWith(`${bunInstall}/node_modules/@agentuity/cli/`)) {
|
|
51
|
+
return 'global';
|
|
52
|
+
}
|
|
53
|
+
// Check for ~/.bun/install/global/node_modules/@agentuity/cli/ (alternative layout)
|
|
54
|
+
if (mainPath.startsWith(`${bunInstall}/install/global/`)) {
|
|
55
|
+
return 'global';
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// GLOBAL DETECTION: Check for legacy ~/.agentuity/ installation
|
|
60
|
+
// The install.sh script may install to ~/.agentuity/node_modules/@agentuity/cli/
|
|
61
|
+
// or create a shim at ~/.agentuity/bin/agentuity
|
|
62
|
+
if (home) {
|
|
63
|
+
const agentuityDir = resolveRealPath(`${home}/.agentuity`);
|
|
64
|
+
if (mainPath.startsWith(`${agentuityDir}/`)) {
|
|
65
|
+
return 'global';
|
|
66
|
+
}
|
|
32
67
|
}
|
|
33
68
|
|
|
34
|
-
//
|
|
35
|
-
|
|
69
|
+
// GLOBAL DETECTION: Fallback check for any path containing /.bun/ before node_modules
|
|
70
|
+
// This catches edge cases where BUN_INSTALL might not match the actual path
|
|
71
|
+
if (mainPath.includes('/.bun/') && mainPath.includes('/node_modules/@agentuity/cli/')) {
|
|
36
72
|
return 'global';
|
|
37
73
|
}
|
|
38
74
|
|
|
39
|
-
//
|
|
75
|
+
// LOCAL DETECTION: Running from a project's node_modules
|
|
76
|
+
// This is when someone runs `bunx agentuity` or has it as a project dependency
|
|
77
|
+
// At this point, we've ruled out global installs, so any node_modules path is local
|
|
40
78
|
if (mainPath.includes('/node_modules/@agentuity/cli/')) {
|
|
41
79
|
return 'local';
|
|
42
80
|
}
|
|
43
81
|
|
|
44
|
-
//
|
|
82
|
+
// SOURCE DETECTION: Running from source code (development)
|
|
83
|
+
// This is when running directly from the monorepo: packages/cli/bin/cli.ts
|
|
45
84
|
return 'source';
|
|
46
85
|
}
|
|
47
86
|
|