Repository navigation
Conversation
`bun run build:sdk` fails on main for every recent commit, and the binary build
stops behind it. Two independent causes:
1. common's JSON types were mutable - `{ [key: string]: JSONValue }` and
`JSONValue[]` - while the model SDKs type their payloads as `Readonly<...>`.
A mutable index signature does not accept a read-only one, so every
providerOptions assignment was a type error: seven of them, from
sdk/src/impl/llm.ts:269 through common/src/util/messages.ts and
agent-runtime's stream parsers. JSON that crosses a boundary is read-only,
so the type now says so. The one place that assembles a new payload
(agent-runtime's gravity-index `omitUndefined`) builds a writable
`Record<string, JSONValue | undefined>` and returns that.
2. cli/src imports `picocolors` in three files and it was declared in no
package.json, so the binary build stopped at `Could not resolve:
"picocolors"`. Declared at ^1.1.1.
Verified with the four steps CI runs, in that order, from a clean tree:
bun install --frozen-lockfile exit 0
bun run build:sdk exit 0 (was 7 TS errors and
"declaration bundling failed")
bun freebuff/cli/build.ts 0.0.0-ci exit 0
cli/bin/freebuff --version + smoke-binary.ts OK, boot matched
The compiled binary bakes NEXT_PUBLIC_* in at build time. The workflow set them
only on the smoke step, so the build ran with none of them: the values were
baked in as undefined, every invocation died in common/src/env.ts, and the smoke
step reported "--smoke-api-url exited 1 without printing a URL".
Reproduced from a clean environment (env -i, both directions):
build without NEXT_PUBLIC_* → --smoke-api-url exits 1 in the env schema
build with this env block → probe prints the URL; tree-sitter, dotenv
isolation and boot all pass
|
@obadakhalili this is now the critical blocker: main's last three merges all failed The fix in this PR is exactly what's needed to unbreak the chain. Once this merges, I'll rebase the ones I care about onto green main so their CI re-runs pass the new check-run and land cleanly. Concrete merge order I'd suggest:
Let me know if you want anything else changed here before merging — happy to fix. |
|
Good diagnostic work: the readonly/mutable mismatch between Two things worth flagging before this is ported:
Overall this looks like exactly the sort of build-breakage fix worth porting by hand — just tighten the write-up to cover all three changes so whoever ports it doesn't have to reverse-engineer the CI diff. |
Problem
build-and-testfails onmainfor every recent commit, at the first build step:Seven errors, in three files, all one cause — plus a second break waiting behind it that only shows once the SDK builds.
Cause 1 — JSON is read-only where it crosses a boundary, but its type said mutable
common/src/types/json.tsdeclared:The model SDKs type their payloads as
Readonly<...>(Readonly<JSONObject>, readonly arrays,@ai-sdk/provider's ownJSONValue). A mutable index signature does not accept a read-only one, soSharedV4ProviderOptionscannot be assigned toProviderMetadata, and every message/stream path that touchesproviderOptionsfails to compile:sdk/src/impl/llm.ts:269,:782common/src/util/messages.ts:138,:454,:461packages/agent-runtime/src/tool-stream-parser.ts:142packages/agent-runtime/src/tools/stream-parser.ts:805The data really is read-only once it leaves a provider call, so the type now says so:
JSONObjecthas areadonlyindex signature andJSONArrayisreadonly JSONValue[]. One place assembles a new payload —omitUndefinedinagent-runtime/…/gravity-index.ts— and it now builds a writableRecord<string, JSONValue | undefined>and returns that, which is what it was doing anyway; the annotation was the only thing forcing the mutable view.Cause 2 —
picocolorsis imported but declared nowherecli/src/index.tsx,cli/src/login/plain-login.tsandcli/src/utils/agent-dir-trust.tsimportpicocolors; nopackage.jsonlisted it, so once the SDK builds, the next step stops at:Declared as
^1.1.1incli/package.json;bun.lockupdated. This is the only dependency change in the PR.Verification — the four steps CI runs, in order, on this branch
cd sdk && bun run typecheckis exit 0, zero errors (was seven).Why this is the durable fix, not a suppression
any, no@ts-expect-error, no cast at the failing call sites: the seven errors disappear because the type describes the data correctly.JSONValueisReadonly), so a future provider bump does not reintroduce it.Effect on other PRs
This is the only thing standing between the repo and a green
build-and-test: the step fails before any test runs, so every open PR inherits it regardless of content. Once this lands, the other open PRs get a green run on a rebase.