feat(agent): add typed server API tools

This commit is contained in:
2026-07-15 10:44:07 +08:00
parent f3f873e3c4
commit 8a21908785
30 changed files with 3119 additions and 15 deletions
+13
View File
@@ -0,0 +1,13 @@
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;
};