feat(media): report USDC cost in image/video/music results#31
Merged
Merged
Conversation
blockrun_image, blockrun_video and blockrun_music returned the URL and model but no price, so on a bare MCP (without the plugin's announce-cost skill) the user never saw what a generation charged — the cost was booked to the budget ledger but never shown. Each now appends a `Cost: $X.XXXX` line and a cost_usd field to structuredContent, matching blockrun_speech and blockrun_realface which already did this. Video and music report the real 402-settled amount (token-priced upstream, so hi-res clips and long tracks can exceed the estimate); image uses the catalog estimate on Base and the 402 amount on Solana, each falling back to the estimate only if the quote doesn't parse. No new spend path — the figure shown is the same amount already recorded to the budget. Adds handler-level tests for the image/video/music footers with the HTTP layer and x402 helpers mocked (no network, no real spend); npm test now runs with --experimental-test-module-mocks.
Contributor
|
Merged via Note: VERSION is now 0.26.0. Heads-up that the 0.25.3 release ( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
blockrun_image,blockrun_video, andblockrun_musicreturn the URL and model but no price. On a bare MCP — without the plugin'sannounce-costskill — the user never sees what a generation charged. The cost is already computed and booked to the budget ledger; it just isn't surfaced in the result.blockrun_speechandblockrun_realfacealready print aCost:line, so this closes the gap on the remaining media tools.Change
Each of the three tools now appends to its result:
Cost: $X.XXXXline in the text outputcost_usdfield instructuredContentCost source, per tool:
amountToUsd(details.amount)). Both are token-priced upstream, so 1080p/4K clips and long tracks can exceed the per-unit estimate — showing the settled figure is the accurate one.No new spend path and no change to what is charged — the figure shown is the same amount already recorded to the budget.
Example (video)
Tests
Adds handler-level tests for the image / video / music footers with the HTTP layer and the x402 payment helpers mocked — no network, no real spend.
node --testisolates each file in its own process, so the module mocks don't leak. The test script now runs with--experimental-test-module-mocks.npm test→ 96 passing.npm run typecheckclean.Not included
chat/chat-anthropic(LLM completions — have a real settled price) and the small-ticket data tools (search,exa,surf,markets,rpc,defi,modal,phone) still omit a cost line. Happy to follow up in a separate PR if wanted — kept this one scoped to the media-generation tools.