mirror of
https://github.com/hanzoai/java-sdk.git
synced 2026-10-30 15:07:36 +00:00
The 09-06 regeneration renamed AgentsApi and ToolsApi to AgentApi and ToolApi and the examples kept the old names, so examples-build failed on main. hanzoai/ci gates a client-lane move on that same test, so every release dispatch since has stopped before regenerating and the jar stayed at 8.5.156, a client with no postDecisions. The client is regenerated from the document api.hanzo.ai serves (hanzo-inc/cloud 151878a3c, sha256 00564264), which now namespaces its schemas (AgentAgentView, ProvisioningProvisionRequest, ToolToolList) and types chat completions, so the examples are rewritten against it: agent, store and tools use the new names and paths, and chat sends a prompt and prints the reply instead of a status. .spec-lock is left to the lane, whose next move records the ref it was handed. hanzo.yml now names where the version lives, scripts/version, so the cut rewrites build.gradle to the release number and the push to main publishes it through release.yml; without it the cut tagged a build.gradle Central already served and nothing published. The README names the 8.5 line (8.5.+, [8.5,8.6)) rather than a patch, because each release cuts a patch into build.gradle alone, and scripts/readme checks the line instead of a number that goes stale. Co-authored-by: Hanzo Dev <[email protected]>
55 lines
1.9 KiB
Java
55 lines
1.9 KiB
Java
package ai.hanzo.cloud.examples;
|
|
|
|
import ai.hanzo.Hanzo;
|
|
import ai.hanzo.cloud.ApiException;
|
|
import ai.hanzo.cloud.api.ToolApi;
|
|
import ai.hanzo.cloud.model.ToolTool;
|
|
import ai.hanzo.cloud.model.ToolToolList;
|
|
|
|
import java.util.List;
|
|
|
|
/**
|
|
* tools — list the tools this key can reach.
|
|
*
|
|
* <p>Operation: {@code get_tool} — GET /v1/tool.
|
|
*
|
|
* <p>The catalogue is per-key: it composes the typed product operations with
|
|
* whatever external servers the caller's org has enabled, so two keys in two
|
|
* orgs see different lists. {@code activated} says which of them this key may
|
|
* actually dispatch, and {@code source} says where each one comes from —
|
|
* printing both is the difference between a catalogue and a menu.
|
|
*
|
|
* <p>(POST /v1/mcp is the JSON-RPC door onto the same catalogue and answers 200
|
|
* with the tool list, but the document does not declare it, so it is not a
|
|
* generated method. GET /v1/tool is the REST view that is.)
|
|
*
|
|
* <pre>
|
|
* HANZO_API_KEY=hk-... ./gradlew :examples:tools
|
|
* </pre>
|
|
*/
|
|
public final class Tools {
|
|
|
|
public static void main(String[] args) {
|
|
ToolApi tools = new ToolApi(Hanzo.client());
|
|
|
|
try {
|
|
ToolToolList catalog = tools.getTool(null, null);
|
|
List<ToolTool> listed = catalog.getTools();
|
|
if (listed == null || listed.isEmpty()) {
|
|
System.out.println("no tools reachable with this key");
|
|
return;
|
|
}
|
|
for (ToolTool tool : listed) {
|
|
System.out.printf("%-32s %-12s %s%n",
|
|
tool.getName(),
|
|
tool.getSource(),
|
|
Boolean.TRUE.equals(tool.getActivated()) ? "activated" : "available");
|
|
}
|
|
System.out.printf("%n%d tools%n", listed.size());
|
|
} catch (ApiException e) {
|
|
System.err.printf("tools failed: HTTP %d %s%n", e.getCode(), e.getResponseBody());
|
|
System.exit(1);
|
|
}
|
|
}
|
|
}
|