@cargo-ai/cli 1.0.23 → 1.0.24
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/build/api.d.ts.map +1 -1
- package/build/api.js +2 -0
- package/build/proxy.d.ts +17 -0
- package/build/proxy.d.ts.map +1 -0
- package/build/proxy.js +65 -0
- package/package.json +4 -2
package/build/api.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,GAAG,EAAY,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,GAAG,EAAY,MAAM,eAAe,CAAC;AAInD,YAAY,EAAE,GAAG,EAAE,CAAC;AAQpB,wBAAgB,SAAS,CAAC,IAAI,EAAE;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,GAAG,SAAS,CAAC;CACnC,GAAG,GAAG,CAQN"}
|
package/build/api.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
2
|
import { buildApi } from "@cargo-ai/api";
|
|
3
|
+
import { getProxyTransport } from "./proxy.js";
|
|
3
4
|
const require = createRequire(import.meta.url);
|
|
4
5
|
const { version } = require("../package.json");
|
|
5
6
|
const ORIGIN = { name: "cli", version };
|
|
@@ -9,5 +10,6 @@ export function createApi(opts) {
|
|
|
9
10
|
workspaceUuid: opts.workspaceUuid,
|
|
10
11
|
accessToken: opts.accessToken,
|
|
11
12
|
origin: ORIGIN,
|
|
13
|
+
transport: getProxyTransport(opts.baseUrl),
|
|
12
14
|
});
|
|
13
15
|
}
|
package/build/proxy.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ClientTransport } from "@cargo-ai/api";
|
|
2
|
+
/**
|
|
3
|
+
* Build Axios transport overrides that tunnel requests through an
|
|
4
|
+
* HTTP/HTTPS proxy when one is configured via the standard proxy env
|
|
5
|
+
* vars (`HTTPS_PROXY`, `HTTP_PROXY`, `ALL_PROXY`, honoring `NO_PROXY`).
|
|
6
|
+
*
|
|
7
|
+
* This works around Axios' unreliable built-in proxy handling, which can
|
|
8
|
+
* fall into a 308 redirect loop (`ERR_FR_TOO_MANY_REDIRECTS`) for HTTPS
|
|
9
|
+
* targets inside proxied environments such as cloud agent sandboxes. We
|
|
10
|
+
* disable Axios' env-based proxy (`proxy: false`) and tunnel via the
|
|
11
|
+
* dedicated proxy agents instead.
|
|
12
|
+
*
|
|
13
|
+
* Returns `undefined` when no proxy applies, so the client keeps its
|
|
14
|
+
* default direct-egress behavior.
|
|
15
|
+
*/
|
|
16
|
+
export declare const getProxyTransport: (targetUrl: string) => ClientTransport | undefined;
|
|
17
|
+
//# sourceMappingURL=proxy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"proxy.d.ts","sourceRoot":"","sources":["../src/proxy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AA4CrD;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,iBAAiB,cACjB,MAAM,KAChB,eAAe,GAAG,SAoBpB,CAAC"}
|
package/build/proxy.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { HttpProxyAgent } from "http-proxy-agent";
|
|
2
|
+
import { HttpsProxyAgent } from "https-proxy-agent";
|
|
3
|
+
const getEnv = (...names) => {
|
|
4
|
+
for (const name of names) {
|
|
5
|
+
const value = process.env[name];
|
|
6
|
+
if (value !== undefined && value.trim() !== "") {
|
|
7
|
+
return value.trim();
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
return undefined;
|
|
11
|
+
};
|
|
12
|
+
const shouldBypassProxy = (targetUrl, noProxy) => {
|
|
13
|
+
if (noProxy === undefined) {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
if (noProxy === "*") {
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
let hostname;
|
|
20
|
+
try {
|
|
21
|
+
hostname = new URL(targetUrl).hostname;
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
return noProxy
|
|
27
|
+
.split(",")
|
|
28
|
+
.map((entry) => entry.trim())
|
|
29
|
+
.filter((entry) => entry.length > 0)
|
|
30
|
+
.some((entry) => {
|
|
31
|
+
const normalized = entry.replace(/^\./, "");
|
|
32
|
+
return hostname === normalized || hostname.endsWith(`.${normalized}`);
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Build Axios transport overrides that tunnel requests through an
|
|
37
|
+
* HTTP/HTTPS proxy when one is configured via the standard proxy env
|
|
38
|
+
* vars (`HTTPS_PROXY`, `HTTP_PROXY`, `ALL_PROXY`, honoring `NO_PROXY`).
|
|
39
|
+
*
|
|
40
|
+
* This works around Axios' unreliable built-in proxy handling, which can
|
|
41
|
+
* fall into a 308 redirect loop (`ERR_FR_TOO_MANY_REDIRECTS`) for HTTPS
|
|
42
|
+
* targets inside proxied environments such as cloud agent sandboxes. We
|
|
43
|
+
* disable Axios' env-based proxy (`proxy: false`) and tunnel via the
|
|
44
|
+
* dedicated proxy agents instead.
|
|
45
|
+
*
|
|
46
|
+
* Returns `undefined` when no proxy applies, so the client keeps its
|
|
47
|
+
* default direct-egress behavior.
|
|
48
|
+
*/
|
|
49
|
+
export const getProxyTransport = (targetUrl) => {
|
|
50
|
+
if (shouldBypassProxy(targetUrl, getEnv("NO_PROXY", "no_proxy"))) {
|
|
51
|
+
return undefined;
|
|
52
|
+
}
|
|
53
|
+
const isHttps = targetUrl.startsWith("https:");
|
|
54
|
+
const proxyUrl = isHttps
|
|
55
|
+
? getEnv("HTTPS_PROXY", "https_proxy", "ALL_PROXY", "all_proxy")
|
|
56
|
+
: getEnv("HTTP_PROXY", "http_proxy", "ALL_PROXY", "all_proxy");
|
|
57
|
+
if (proxyUrl === undefined) {
|
|
58
|
+
return undefined;
|
|
59
|
+
}
|
|
60
|
+
return {
|
|
61
|
+
httpAgent: new HttpProxyAgent(proxyUrl),
|
|
62
|
+
httpsAgent: new HttpsProxyAgent(proxyUrl),
|
|
63
|
+
proxy: false,
|
|
64
|
+
};
|
|
65
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cargo-ai/cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.24",
|
|
4
4
|
"private": false,
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"description": "Command-line interface for the Cargo API",
|
|
@@ -29,10 +29,12 @@
|
|
|
29
29
|
"format:check": "prettier --check ."
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@cargo-ai/api": "^1.0.
|
|
32
|
+
"@cargo-ai/api": "^1.0.29",
|
|
33
33
|
"@cargo-ai/app-sdk": "^1.0.2",
|
|
34
34
|
"@cargo-ai/worker-sdk": "^1.0.2",
|
|
35
35
|
"commander": "^12.1.0",
|
|
36
|
+
"http-proxy-agent": "^9.1.0",
|
|
37
|
+
"https-proxy-agent": "^9.1.0",
|
|
36
38
|
"tsx": "^4.19.2"
|
|
37
39
|
},
|
|
38
40
|
"devDependencies": {
|