Commit graph

8 commits

Author SHA1 Message Date
Simon Klee
ce0c29bcd7
fix(cli-rs): write whole numbers as integers in request bodies
The generated types use f64 for protocol numbers that are not integer
schemas, and serde writes a whole f64 as 3.0 where JSON.stringify writes
3. The generator now puts a serialize_with helper on every f64 field,
alias and union member, so request bodies match the TypeScript client
byte for byte. The F.2 oracle covers mention offsets and form answers.
2026-11-04 20:58:23 +01:00
Simon Klee
26cfacbbf9
fix(cli-rs): fix the API types carbon found wrong in F.2
carbon-1: a union member that is itself a union with several tags joins the
outer tag, so SessionLogItem routes log.synced to LogSynced and its tag()
delegates to the inner enum.
carbon-2: Schema.NonEmptyArray(T) is Vec<T>, so form fields and tool
content are typed (FormField, ToolContent).
carbon-3: Ref_1 twins that Rust decodes the same as Ref share its type
(FormInfo, ShellInfo, FormAnswer, the inbox payloads, message parts).
carbon-4: untagged unions get a generated Deserialize that skips a member
whose required literal field holds another value, so an LSP server entry
with disabled: false keeps its command.
carbon-5: generated errors implement TaggedError, and DeclaredError::decode
checks the tag.

Call sites in crates/store and crates/ui follow the renamed types.
2026-11-04 19:51:14 +01:00
Simon Klee
d6a1d29a68
fix(cli-rs): tag message unions whose members are unions
Session.Message.Info has a Compaction member that is itself a union tagged by status, so the generator fell back to an untagged enum. serde then decoded an assistant message as the first member that fits (AgentSelected). Nested unions now join the outer tag when all their objects share one value.
2026-11-04 18:48:51 +01:00
Simon Klee
7baefa3f36
fix(cli-rs): keep JSON key order in generated records
Records decoded into BTreeMap, which sorts keys. The TUI prints tool inputs in wire order (primitiveInputSummary, the fallback JSON title), so records are now IndexMap; serde_json already preserves order.
2026-11-04 18:34:12 +01:00
Simon Klee
0f63e545d7
chore(cli-rs): format the API generator and type the oracle's fetch
Prettier over script/gen/api.ts and script/rust; the oracle's fake fetch no
longer casts to typeof fetch, so bun check passes. Output is unchanged.
2026-11-04 18:20:48 +01:00
Simon Klee
34e9ec7d47
test(cli-rs): prove API requests and decoding against the TS client
A P-ORACLE fixture records the requests the TypeScript Promise client builds;
the generated Rust client must build the same ones, and query::append must
match appendQuery. Unit tests cover tagged unions (known, rpc.*, unknown),
literal enums, double options, declared errors, binary bodies, auth, and
the event stream through F.3's SSE reader.
2026-11-04 18:20:48 +01:00
Simon Klee
a477234497
feat(cli-rs): share one type for equal anonymous API shapes
Every endpoint's location query decoded into its own struct; equal anonymous
objects and unions now share one, and the location query is LocationQueryInput.
2026-11-04 18:20:48 +01:00
Simon Klee
cc409d1fcf
feat(cli-rs): generate the Rust API client from ClientApi
script/gen/api.ts compiles ClientApi with the Promise client's options and emits
types and one method per endpoint (166) into crates/api/src/generated. The
request core, errors, query encoding, and the reqwest transport are written
by hand. Tagged unions decode through a generated Deserialize that keeps
unknown members and routes rpc.* events.
2026-11-04 18:20:48 +01:00