HTTP 回调工具代理。
外部系统通过 POST /v1/sessions/:id/tools 注册自定义工具,
Agent 调用时 Gateway 向 callback_url 发 POST 请求,代理执行结果。
注册请求体
{
"name": "query_database",
"description": "Run a SQL query on the production database",
"parameters": {
"type": "object",
"properties": {
"query": {"type": "string", "description": "SQL query to execute"}
},
"required": ["query"]
},
"callbackUrl": "https://my-service.example.com/tools/query",
"timeoutMs": 30000
}回调请求格式
Gateway 向 callbackUrl 发 POST:
{
"callId": "tc_abc123",
"toolName": "query_database",
"args": {"query": "SELECT * FROM users LIMIT 10"},
"sessionId": "s-001"
}回调响应格式
{"result": "10 rows returned..."}
// 或错误
{"error": "Connection refused"}
Summary
Functions
清理指定 session 的所有回调工具。
初始化 ETS 注册表(由 Application 调用)。
获取指定 session 的所有已注册回调工具模块。
为指定 session 注册一个回调工具。
Types
@type tool_spec() :: %{ name: String.t(), description: String.t(), parameters: map(), callback_url: String.t(), timeout_ms: pos_integer() }
Functions
@spec cleanup(String.t()) :: :ok
清理指定 session 的所有回调工具。
@spec execute_callback(tool_spec(), String.t(), String.t(), map()) :: {:ok, String.t()} | {:error, String.t()}
执行 HTTP 回调。
向 callback_url 发送 POST 请求,传递工具调用参数,返回结果。
@spec init_registry() :: :ok
初始化 ETS 注册表(由 Application 调用)。
获取指定 session 的所有已注册回调工具模块。
为指定 session 注册一个回调工具。
返回动态生成的 Tool 模块原子。