fix: always populate user-agent (#708)
This commit is contained in:
24
src/agent/http-headers.ts
Normal file
24
src/agent/http-headers.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import packageJson from "../../package.json";
|
||||
|
||||
/**
|
||||
* Get standard headers for manual HTTP calls to Letta API.
|
||||
* Use this for any direct fetch() calls (not SDK calls).
|
||||
*/
|
||||
export function getLettaCodeHeaders(apiKey?: string): Record<string, string> {
|
||||
return {
|
||||
"Content-Type": "application/json",
|
||||
"User-Agent": `letta-code/${packageJson.version}`,
|
||||
"X-Letta-Source": "letta-code",
|
||||
...(apiKey ? { Authorization: `Bearer ${apiKey}` } : {}),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Get headers for MCP OAuth connections (includes Accept header for SSE).
|
||||
*/
|
||||
export function getMcpOAuthHeaders(apiKey: string): Record<string, string> {
|
||||
return {
|
||||
...getLettaCodeHeaders(apiKey),
|
||||
Accept: "text/event-stream",
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user