Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1716,6 +1716,13 @@ function buildDemoSessions(): DemoSession[] {
];
}

function jsonAuthHeaders(): Record<string, string> {
const headers: Record<string, string> = { "Content-Type": "application/json" };
const secret = process.env["AGENTMEMORY_SECRET"];
if (secret) headers["Authorization"] = `Bearer ${secret}`;
return headers;
}

async function postJson<T = unknown>(
url: string,
body: unknown,
Expand All @@ -1724,7 +1731,7 @@ async function postJson<T = unknown>(
try {
const res = await fetch(url, {
method: "POST",
headers: { "Content-Type": "application/json" },
headers: jsonAuthHeaders(),
body: JSON.stringify(body),
signal: AbortSignal.timeout(timeoutMs),
});
Expand All @@ -1742,7 +1749,7 @@ async function postJsonStrict<T = unknown>(
): Promise<T | null> {
const res = await fetch(url, {
method: "POST",
headers: { "Content-Type": "application/json" },
headers: jsonAuthHeaders(),
body: JSON.stringify(body),
signal: AbortSignal.timeout(timeoutMs),
});
Expand Down