14 lines
672 B
TypeScript
14 lines
672 B
TypeScript
const internalBaseUrl = process.env.TJWATER_AGENT_INTERNAL_BASE_URL ?? "http://127.0.0.1:8787";
|
|
const internalToken = process.env.TJWATER_AGENT_INTERNAL_TOKEN ?? "";
|
|
|
|
export const callServerApiTool = async (name: string, args: unknown, sessionID: string) => {
|
|
const response = await fetch(`${internalBaseUrl}/internal/tools/server-api/${name}`, {
|
|
method: "POST",
|
|
headers: { "Content-Type": "application/json", "x-agent-internal-token": internalToken },
|
|
body: JSON.stringify({ session_id: sessionID, args }),
|
|
});
|
|
const text = await response.text();
|
|
if (!response.ok) throw new Error("TJWater domain tool bridge rejected the request");
|
|
return text;
|
|
};
|