Files
zeekay 7098a20d92 client: the document is the one cloud emits, named by commit
This client read hanzoai/openapi's hanzo.yaml at branch `main` and carried no
lock, so it named its document by something that moves and could not say which
bytes it was a projection of. It now reads what hanzoai/cloud emits, at the
commit .spec-lock names, digest-checked on every fetch — the same document and
the same four-line receipt every other Hanzo client carries. This repo's own
hanzo.yml had already declared that move; the script had not made it, so the
lane and the script named two different documents.

Nothing is lost, measured route by route: cloud's document is a strict SUPERSET
of the projection — 2479 operations against 2456, with 0 routes only in
hanzo.yaml and 23 only in cloud. The projection's one addition for this
language, a `default` response injected into every operation that declares
none, buys nothing here: a `default` with no content produces the same void
return that no `responses` does, so both documents yield the identical 834
void-returning methods. Generated, that is 2502 methods against 2455 committed.

The 7.24.0 generator floor is gone, and it was not wrong when written — both
defects it named lived in schemas the document no longer carries
(vector_NamedVectors under additionalProperties, framework_Document.docstatus).
Re-measured at the locked commit, 7.14.0 and 7.24.0 emit the same library apart
from the version string in each file's header and one doc comment on
ConsoleSettings::getOidcConfig. So this repo is on the fleet's 7.14.0 pin and is
no longer an exception on version. It stays out of sdks.yaml for one reason
only, and that one is measured too: without templates/cpp-restsdk the library
fails with 8 errors in ModelBase.h, and a template is a file that has to sit
beside the invocation.

One flag joins the invocation, and it is the fleet's own. o11y.GettableAgentCheckIn
publishes integration_config beside integrationConfig and removed_at beside
removedAt so older agents keep working; C++ camel-cases a property into its
accessor, so each pair declared one method twice and the library did not
compile. Renaming the accessor keeps both wire keys — all four are present in
the emitted model, each under its own name — which is what the python, go,
java, kotlin, ruby and php rows already do for the same two schemas.

Four flows changed route, none of them because of this move: their old
operations are untyped or absent in hanzo.yaml too, measured by regenerating
from it, so the committed tree simply predated the change. hello, chat, money
and tools move to the typed route for the same job; agent keeps its route and
reads the run from the typed list, because the run POST declares no body and no
response. Each says so in its own header, and the rule they follow is that an
example has to demonstrate a call the document types.

packageVersion leaves the invocation as inert: measured with a sentinel it
reaches the generator's own README and no file under include/ or src/, so the
library version in CMakeLists.txt is this repo's to choose and is coupled to
nothing.

Measured on aarch64 Ubuntu 24.04, g++ 13.3, generator 7.14.0, document
49389cf9: 2663 sources, library 0 errors, six examples 0 errors.
2026-08-14 20:28:34 -07:00

46 lines
1.8 KiB
C++

// chat — ask one question, print the grounded answer and what it cited.
//
// Operation: research_web (POST /v1/ask/web), on AskApi.
//
// NOT /v1/chat/completions. That route is real and this client carries it, but
// the document declares it with no request body and no response schema, so the
// generated method takes nothing and returns nothing — there is no typed way to
// send a message or read a reply through it. A generated client can only be as
// typed as the document, and an example has to demonstrate a call that works.
// /v1/ask/web is the typed one: a question in, an answer with its sources out.
//
// Non-streaming on purpose: streaming is a different transport (SSE) that a
// generated client returns as an opaque body, so demonstrating it here would
// teach the wrong shape.
//
// HANZO_API_KEY=hk-... ./build/examples/chat
#include <iostream>
#include "hanzo.h"
#include "hanzo/api/AskApi.h"
int main() {
using namespace hanzo;
try {
auto question = std::make_shared<model::WebQuestion>();
question->setQ(U("Name the three laws of thermodynamics in one line each."));
question->setMode(U("search"));
question->setMaxSources(3);
api::AskApi ask(examples::client());
std::shared_ptr<model::Report> report = ask.researchWeb(question).get();
examples::print(U("model "), report->getModel());
examples::print(U("answer "), report->getAnswer());
// Every citation is a page the call fetched, so the sources are part of
// the answer rather than decoration.
for (const auto& source : report->getSources()) {
examples::print(U("source "), source->getUrl());
}
} catch (const std::exception& e) {
return examples::fail(U("chat"), e);
}
return 0;
}