MCPcopy Index your code
hub / github.com/CommandCodeAI/BaseAI / send

Method send

packages/core/src/common/request.ts:44–80  ·  view source on GitHub ↗
({endpoint, ...options}: SendOptions)

Source from the content-addressed store, hash-verified

42 }
43
44 private async send<T>({endpoint, ...options}: SendOptions): Promise<T> {
45 const url = this.buildUrl({endpoint});
46 const headers = this.buildHeaders({headers: options.headers});
47
48 let response: Response;
49 try {
50 response = await this.makeRequest({
51 url,
52 options: {...options, endpoint},
53 headers,
54 });
55 } catch (error) {
56 throw new APIConnectionError({
57 cause: error instanceof Error ? error : undefined,
58 });
59 }
60
61 if (!response.ok) {
62 await this.handleErrorResponse({response});
63 }
64
65 const threadId = response.headers.get('lb-thread-id');
66
67 if (options.body?.stream) {
68 return handleResponseStream({
69 response,
70 rawResponse: options.body.rawResponse,
71 }) as T;
72 }
73
74 return this.handleRunResponse({
75 response,
76 isChat: options.body?.chat,
77 threadId,
78 rawResponse: options.body?.rawResponse ?? false,
79 });
80 }
81
82 private buildUrl({endpoint}: {endpoint: string}): string {
83 return `${this.config.baseUrl}${endpoint}`;

Callers 4

postMethod · 0.95
getMethod · 0.95
putMethod · 0.95
deleteMethod · 0.95

Calls 7

buildUrlMethod · 0.95
buildHeadersMethod · 0.95
makeRequestMethod · 0.95
handleErrorResponseMethod · 0.95
handleRunResponseMethod · 0.95
handleResponseStreamFunction · 0.90
getMethod · 0.80

Tested by

no test coverage detected