Credit balance as a DECIMAL STRING, e.g. '950' — not a bigint.
⚠️ It is a string because that is what the deserializer produces, not as a
preference. PlanBalance is constructed nowhere in src/: it only ever
arrives from getPlanBalance, which ends in a bare return response.json(),
and JSON has no bigint. It had been declared bigint since 2025-05-26 while the API sent a
quoted string, so balance > 100n threw Cannot mix BigInt and other types
in code that typechecked clean, and typeof balance === 'bigint' silently
took the wrong branch. This reaches sellers as public API — PlanBalance is
on req.paymentContext.agentRequest.balance.
The value can exceed Number.MAX_SAFE_INTEGER, so do NOT route it through
Number. For arithmetic, convert explicitly:
BigInt(ctx.agentRequest.balance.balance) > 100n
The outbound direction already has its counterpart: jsonReplacer
(common/helper.ts) narrows bigints to strings on request bodies. This is
the inbound side of the same boundary.
Credit balance as a DECIMAL STRING, e.g.
'950'— not abigint.⚠️ It is a string because that is what the deserializer produces, not as a preference.
PlanBalanceis constructed nowhere insrc/: it only ever arrives fromgetPlanBalance, which ends in a barereturn response.json(), and JSON has no bigint. It had been declaredbigintsince 2025-05-26 while the API sent a quoted string, sobalance > 100nthrewCannot mix BigInt and other typesin code that typechecked clean, andtypeof balance === 'bigint'silently took the wrong branch. This reaches sellers as public API —PlanBalanceis onreq.paymentContext.agentRequest.balance.The value can exceed
Number.MAX_SAFE_INTEGER, so do NOT route it throughNumber. For arithmetic, convert explicitly:The outbound direction already has its counterpart:
jsonReplacer(common/helper.ts) narrows bigints to strings on request bodies. This is the inbound side of the same boundary.