mirror of
https://github.com/hanzoai/swift-sdk.git
synced 2026-10-30 18:20:19 +00:00
This repo existed twice: the forge carried a client regenerated against cloud 70b374b9, github carried one against 54ddf3d6 — its ancestor — plus the examples, hanzo.yml and .gitignore the forge line never had. Neither was a superset, so neither could simply overwrite the other. Merged: the newer generation, and everything only the other line had. The flows had rotted against it exactly as the gate exists to prevent, because the regeneration and the examples were on opposite lines: the newer document tags those operations under AiAPI, and drops /v1/keys entirely. models calls AiAPI, hello calls ToolsAPI.getTools — typed, and still the call that refuses without a credential. hanzo.yml now gates the tree that carries both, so the next such move breaks in CI rather than in a reader's editor.
26 lines
739 B
Swift
26 lines
739 B
Swift
// hello — prove the key works, and print what it can reach.
|
|
//
|
|
// HANZO_API_KEY=sk-… swift run --package-path examples hello
|
|
//
|
|
// GET /v1/tools declares a response schema, so this one comes back typed:
|
|
// `ToolList` of `Tool`. It is the flow that FAILS on a bad credential — that is
|
|
// the point of it — where models succeeds with none.
|
|
|
|
import Foundation
|
|
import Flow
|
|
import Hanzo
|
|
|
|
Flow.configure()
|
|
|
|
do {
|
|
let tools = try await ToolsAPI.getTools().tools ?? []
|
|
|
|
print("\(tools.count) tools reachable at \(Flow.base)")
|
|
for tool in tools.prefix(10) {
|
|
print(" \(tool.name ?? "(unnamed)")")
|
|
}
|
|
} catch {
|
|
// Typed throws: `error` is an ErrorResponse here, and nothing else can be.
|
|
Flow.fail(error)
|
|
}
|