fix(cloud-apps): withdraw amount + app reference miss planner-nested options.parameters — full-balance withdrawal bug - #11810
Conversation
…amount + app reference
MONEY (HIGH): parseWithdrawAmount read AMOUNT_OPTION_KEYS on top-level
options only, but the real planner path nests validated args under
options.parameters (execute-planned-tool-call.ts sets
handlerOptions.parameters = validation.args). 'withdraw fifty dollars
from Acme' therefore parsed no amount and staged the FULL withdrawable
balance, which a confirm then withdrew. Amounts are now read from the
nested parameters object first, then top-level, then text — mirroring
readStructuredConfirmation (safety.ts) and actionParams (domain-intent.ts)
via a new shared plannerOptionSources helper in client.ts.
Also tightens the bare-number text fallback so a digit glued into an app
name ('withdraw my Acme2 earnings') can never read as a $2.00 amount:
the number must be a standalone whitespace-bounded token not followed by
an alphanumeric.
Shared: extractAppReference had the same top-level-only miss; every
action that resolves an app by reference now sees the nested planner
shape first.
Tests: nested {parameters:{amount:50}} / {parameters:{appName:...}}
planner-shape coverage (unit + full two-phase handler regression), the
Acme2 digit-in-name regression, and standalone-token amount parsing.
bun test plugins/plugin-cloud-apps: 275 pass / 0 fail; tsgo + biome clean.
There was a problem hiding this comment.
Your trial has ended. Reactivate Greptile to resume code reviews.
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Post-merge validation pass from a clean PR worktree rebased on current develop:
Reviewed the money-flow invariant: the first ask now reads nested planner |
…nblock ALL deploys (#11847) Every develop deploy since ~03:46 UTC failed at the Deploy API Worker step: No matching export in "src/stubs/elizaos-core.ts" for import "runWithTrajectoryPurpose" (shared/src/email-classification/email-classifier.ts:20) email-classifier (@elizaos/shared, pulled into the Worker bundle transitively) imports runWithTrajectoryPurpose from @elizaos/core, which the Worker aliases to this stub — but the stub only had runWithTrajectoryContext, not the newer runWithTrajectoryPurpose (added to core in trajectory-context.ts). So the esbuild bundle failed and NO deploy could ship — blocking the develop→main promote that carries the merged money fixes (#11810 withdraw, #11817 book-influencer, #11686 sweep) to prod. Fix: add the Worker-safe stub mirroring runWithTrajectoryContext — no trajectory context manager exists in the Worker bundle (it lives on the agent sidecar and this path is never invoked on a Worker route), so just run the fn. Verified: `wrangler deploy --env production --dry-run` now builds clean (15.8 MB bundle, no missing-export error).
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
What
Two nested-planner-args misses in
plugin-cloud-apps, one of them a HIGH money bug on theWITHDRAW_APP_EARNINGSpath.1. HIGH (money):
parseWithdrawAmountmissed the planner's validated amount → staged the FULL balanceparseWithdrawAmount(src/actions/withdraw-app-earnings.ts) readAMOUNT_OPTION_KEYS(amount/usd/value) on top-level options only. But the real planner path nests validated args underoptions.parameters—packages/core/src/runtime/execute-planned-tool-call.tssetshandlerOptions.parameters = validation.args.Failure: "withdraw fifty dollars from Acme" → planner extracts
amount: 50intooptions.parameters→parseWithdrawAmountmisses it, the prose has no digits →requested = null→ the handler stages the full withdrawable balance and the confirm prompt asks about the wrong number. A user confirming withdraws everything instead of $50.Fix: read the nested
options.parametersobject first, then top-level, then the text regexes — exactly mirroringreadStructuredConfirmation(safety.ts) andactionParams(domain-intent.ts), via a new sharedplannerOptionSourceshelper inclient.ts.Also tightened the bare-number text fallback: the number must now be a standalone whitespace-bounded token not followed by an alphanumeric, so a digit glued into an app name ("withdraw my Acme2 earnings") can never read as a $2.00 amount.
$50/50 dollars/50 usd/ standalonewithdraw 50all still parse.2. Shared:
extractAppReferencehad the same top-level-only missextractAppReference(src/client.ts) readREFERENCE_OPTION_KEYSon top-level only, so on the real planner path a validatedappNamewas ignored and resolution fell back to fuzzy-matching the raw message text. Now nested-first via the same helper — this fixes app-by-reference resolution for every action that uses it (withdraw, delete, update, monetization, deploy, backup, key rotation, frontend, ad slots, domains).Why the existing tests missed it
Every existing test passed options top-level (
{ confirm: true },{ appName: ... }) — the direct-call shape — never the planner's nested{ parameters: { ... } }shape. New tests exercise the nested shape end-to-end.Tests (all real — SDK boundary faked only, per plugin convention)
{ parameters: { appName: "Acme Bot", amount: 50 } }+ digit-free prose stages $50.00 (not the $100 balance); nested{ parameters: { confirm: true } }then withdraws exactly 50 via the idempotent endpoint. Fails on the old code (staged $100, withdrew 100).below_thresholdrefusal off the phantom $2).parseWithdrawAmountunit coverage: nested-first precedence, top-level fallback, string/$1,250.50coercion, non-positive rejection, standalone-token text parsing,Acme2/App2000/a1b2/50knever parse as amounts.extractAppReferenceunit coverage: nested planner shape (appName/app/appId), nested-over-top precedence, top-level fallback, text fallback.Verification
bun test plugins/plugin-cloud-apps→ 275 pass / 0 fail (28 files)tsgo --noEmit(plugin typecheck) → cleanbiome check plugins/plugin-cloud-apps→ clean, no fixesEvidence notes
execute-planned-tool-call.ts:270produces).[cloud-money] review requested — money-out path. cc lane charter #11157.
Signed: [cloud-security]