MCPcopy
hub / github.com/continuedev/continue / getAgentOptions

Function getAgentOptions

packages/fetch/src/getAgentOptions.ts:7–52  ·  view source on GitHub ↗
(
  requestOptions?: RequestOptions,
)

Source from the content-addressed store, hash-verified

5 * Prepares agent options based on request options and certificates
6 */
7export async function getAgentOptions(
8 requestOptions?: RequestOptions,
9): Promise<{
10 [key: string]: any;
11}> {
12 const TIMEOUT = 7200; // 7200 seconds = 2 hours
13 const timeout = (requestOptions?.timeout ?? TIMEOUT) * 1000; // measured in ms
14
15 const certsCache = CertsCache.getInstance();
16 const ca = await certsCache.getCa(requestOptions?.caBundlePath);
17
18 const agentOptions: { [key: string]: any } = {
19 ca,
20 rejectUnauthorized: requestOptions?.verifySsl,
21 timeout,
22 sessionTimeout: timeout,
23 keepAlive: true,
24 };
25
26 // Handle ClientCertificateOptions
27 if (requestOptions?.clientCertificate) {
28 const { cert, key, passphrase } = requestOptions.clientCertificate;
29
30 agentOptions.cert = getCertificateContent(cert);
31 agentOptions.key = getCertificateContent(key);
32
33 if (requestOptions.clientCertificate.passphrase) {
34 agentOptions.passphrase = passphrase;
35 }
36 }
37
38 if (process.env.VERBOSE_FETCH) {
39 console.log(`Fetch agent options:`);
40 console.log(`\tTotal CA certs: ${ca.length}`);
41 console.log(`\tGlobal/Root CA certs: ${certsCache.fixedCa.length}`);
42 console.log(`\tCustom CA certs: ${ca.length - certsCache.fixedCa.length}`);
43 console.log(
44 `\tClient certificate: ${requestOptions?.clientCertificate ? "Yes" : "No"}`,
45 );
46 console.log(
47 `\trejectUnauthorized/verifySsl: ${agentOptions.rejectUnauthorized ?? "not set (defaults to true)"}`,
48 );
49 }
50
51 return agentOptions;
52}

Callers 3

fetchwithRequestOptionsFunction · 0.85

Calls 4

getCertificateContentFunction · 0.85
getCaMethod · 0.80
logMethod · 0.65
getInstanceMethod · 0.45

Tested by

no test coverage detected