Commit Graph

1079 Commits

Author SHA1 Message Date
lky-spec
d481b3d88c Remove local-only agent artifacts 2026-04-27 10:51:09 +08:00
lky-spec
e8eafce1e0 Require explicit agent mutation targets 2026-04-26 22:38:16 +08:00
lky-spec
ce3a8582af Simplify agent skill routing and config updates 2026-04-26 22:22:12 +08:00
lky-spec
cfd91069d3 Centralize active skill field extraction 2026-04-26 20:44:09 +08:00
lky-spec
903eb591eb Improve active skill schema handling 2026-04-26 11:58:29 +08:00
lky-spec
9ee931ee30 v2 2026-04-25 20:24:46 +08:00
lky-spec
c244e4cdf1 change v1 2026-04-25 16:18:45 +08:00
lky-spec
737f9bca95 Enhance NOFXi agent workflow and diagnostics 2026-04-19 16:06:28 +08:00
lky-spec
5c4e7502d7 feat: integrate NOFXi agent into dev 2026-04-18 16:06:42 +08:00
shinchan-zhai
851f152c50 fix(wallet): handle JSON-RPC null error field in balance query
Some RPC implementations return explicit "error": null on success.
json.RawMessage deserializes this as the 4-byte literal "null", so
len() > 0 was true, causing every balance query to fail with
"rpc error: null". Skip the null literal to avoid false positives.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-17 11:26:49 +08:00
shinchan-zhai
beb23c369f Merge branch 'dev' of https://github.com/NoFxAiOS/nofx into dev 2026-04-17 11:17:24 +08:00
Lance
0a1a2923dc fix(auth): prevent SetupPage remount from wiping freshly-set auth token (#1481)
After #1470 moved routing into react-router, SetupPage is rendered at two
different tree positions (top-level guard + /setup Route). When register
success flushSync-sets `user`, the top-level guard stops matching and the
Route-level SetupPage mounts as a new instance, re-running its cleanup
useEffect and removing the auth_token that handlePostAuthSuccess just wrote.
Subsequent requests 401 and bounce the user back to /login.

Redirect /setup to /welcome when user is already set so SetupPage is never
re-mounted during the auth transition.
2026-04-17 11:17:17 +08:00
root
117d2f7fd4 feat(trader): honor OKX margin mode and explicitly route nofx data via claw402 wallet (#1476)
Merges PR #1476 from deanokk with the following additions:
- OKX margin mode fix: cross/isolated honored end-to-end via mgnMode/tdMode
- claw402 wallet routing fix: trader path now explicitly resolves user wallet
- refactor: ResolveClaw402WalletKey extracted to store layer (no duplication)
- OKX SetMarginMode documented as local-state-only (no legacy API call)
- OKX margin mode tests expanded: cross mode, OpenShort, SetTakeProfit
2026-04-17 10:57:51 +08:00
root
802590c2b9 refactor: extract ResolveClaw402WalletKey to store layer and expand OKX margin mode tests
- Move duplicated claw402 wallet resolution logic into store.AIModelStore.ResolveClaw402WalletKey
- api/strategy.go and manager/trader_manager.go now delegate to the shared method
- Add detailed doc comment on OKX SetMarginMode explaining the local-state-only approach
  and why the legacy /api/v5/account/set-isolated-mode endpoint is not called
- Add 3 new test cases: cross mode leverage, OpenShort tdMode, SetTakeProfit tdMode
2026-04-17 10:57:42 +08:00
shinchan-zhai
f5891aa39c fix(gemini): update default model to gemini-3.1-pro
Google discontinued gemini-3-pro-preview on 2026-03-26 and directs all
callers to gemini-3.1-pro / gemini-3.1-pro-preview. Users on their own
API key were getting errors from the native Gemini endpoint because the
provider default pointed at the retired ID. Claw402 was unaffected
because its route map already used gemini-3.1-pro.

Align both the native provider default and the handler's preset list
with gemini-3.1-pro so every code path sends a live model ID.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-17 01:14:31 +08:00
Lance
a1f909adbe fix(telemetry): report token usage for SSE streaming paths (#1475)
* fix(telemetry): report token usage for SSE streaming paths

ParseSSEStream already parsed the usage block from SSE chunks but only
printed it, so claw402 streaming calls (and native streaming) never
fired TokenUsageCallback. GA4 therefore undercounted AI usage on the
streaming path.

Return the parsed usage from ParseSSEStream and have both callers fire
the callback with their own Provider/Model.

* chore: drop leftover debug Printf in ParseSSEStream

Telemetry is now wired via TokenUsageCallback, so the Printf is
redundant noise in the stream path.
2026-04-16 21:31:13 +08:00
Lance
2f483633ed feat(claw402): preflight USDC balance before AI calls (#1479)
* chore: ignore nofx-server build artifact

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* feat(claw402): preflight USDC balance before AI calls

Short-circuit claw402 Call/CallWithRequestFull when the wallet balance
can't cover the estimated cost of the call, surfacing ErrInsufficientFunds
instead of letting x402 fail mid-flight after the sign step.

- wallet: cached balance lookup (30s TTL, per-address mutex) to avoid
  hammering the Base RPC; separate error-returning and display-only APIs
  so callers can distinguish zero balance from an unreachable RPC.
- claw402: 1.5× safety multiplier on the flat per-call estimate, 4.0×
  for reasoner models whose chain-of-thought cost can blow past the
  flat rate. Fail-open on RPC errors — x402 still gates actually-empty
  wallets, and we prefer availability over extra strictness.
- shortAddr redacts the wallet in error strings to avoid leaking the
  full address into telemetry bundles.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-16 21:17:45 +08:00
Dean
b9b0a52137 feat(trader): add claw402 wallet key resolution for trader configuration
Implemented a new method, `resolveTraderDataWalletKey`, to retrieve the claw402 wallet key based on the selected AI model and user ID. This enhancement allows for better integration of the claw402 model within the trader configuration, ensuring that the correct wallet key is used for trading operations. The `AutoTraderConfig` struct has been updated to include the new `Claw402WalletKey` field, improving the overall handling of wallet keys in the trading process.
2026-04-15 18:50:31 +08:00
Dean
0d74c27be2 refactor(api): streamline claw402 wallet key retrieval and error handling
Refactored the strategy handling logic to encapsulate claw402 wallet key retrieval in a new method, `resolveStrategyDataWalletKey`. This improves code readability and maintains consistent error handling for missing or invalid wallet keys during strategy test runs. The changes enhance the overall robustness of the AI model integration.
2026-04-15 18:34:20 +08:00
Dean
1464cedeff feat(api): enhance strategy handling by integrating claw402 wallet key validation
Added validation for the claw402 model's wallet key during strategy test runs. If the selected AI model is claw402, the server now checks for a valid wallet key and returns appropriate error messages if it's missing or if the model fails to load. This ensures better error handling and user feedback when working with AI models.
2026-04-15 18:15:32 +08:00
Dean
c2fc80e269 refactor(trader): update SetMarginMode to avoid legacy endpoint and improve logging 2026-04-14 23:34:35 +08:00
Dean
a3d8831b36 feat(trader): implement margin mode handling for order and leverage settings 2026-04-14 17:42:05 +08:00
deanokk
e1b5a5d833 refactor: replace window.location with useNavigate for routing in auth components (#1470)
Co-authored-by: Dean <afei.wuhao@gmail.com>
2026-04-13 23:44:14 +08:00
shinchan-zhai
eef78b7987 fix: allow model switching without re-entering wallet key
Users with existing wallets could not switch AI models because the
"Start Trading" button required a valid private key even when one was
already configured. Now the button is enabled when hasExistingWallet
is true, and handleSubmit passes an empty key so the backend preserves
the existing key.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-12 11:42:14 +08:00
deanokk
a1af4fec58 feat(store): prevent deletion of active strategies and update translations (#1461)
Co-authored-by: Dean <afei.wuhao@gmail.com>
2026-04-11 01:09:13 +08:00
shinchan-zhai
6fe849c18d fix: update frontend default model references from DeepSeek to GLM
Backend was changed to GLM-5 in 8a0f3f5 but frontend still had
hardcoded DeepSeek fallback and onboarding copy.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-10 22:47:35 +08:00
shinchan-zhai
4f0a922779 feat: add "forgot account" reset flow with wallet preservation
Add account reset functionality for users who forgot their login credentials.
The reset clears authentication data while preserving wallet private keys and
exchange configs, which are automatically adopted by the new account on
re-registration to prevent fund loss.

- Add POST /api/reset-account endpoint
- Add "Forgot account?" button on login page (zh/en/id)
- Orphan ai_models and exchanges are re-assigned to new user on register
- Onboarding reuses existing claw402 wallet instead of generating new one

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-10 18:00:56 +08:00
deanokk
80272c0d5a fix(dashboard): preserve trader selection in URL and silence background requests (#1459)
* refactor: streamline trader selection logic and URL handling in App component

* refactor: update API request handling across components to use silent mode for improved error management

---------

Co-authored-by: Dean <afei.wuhao@gmail.com>
2026-04-04 17:16:47 +08:00
shinchan-zhai
8a0f3f5a13 feat: change claw402 default model from deepseek to glm-5 2026-04-04 14:48:42 +08:00
Zavier
0c1f438cc3 fix: improve trader error feedback, stale balance cleanup, and claw402 warnings (#1452)
* fix: improve trader error handling and balance validation

* fix: localize structured trader failure reasons

---------

Co-authored-by: apple <apple@MacbookPro-zbh.local>
2026-04-01 22:10:29 +08:00
deanokk
9a80f1d88d feat: add exchange account states and refine beginner trader creation flow (#1450)
* feat: implement exchange account state management and UI updates

- Added functionality to invalidate exchange account state cache on exchange config updates, creation, and deletion.
- Introduced new API endpoint to fetch exchange account states.
- Updated frontend components to display exchange account states, including status and balance information.
- Enhanced user experience by refreshing exchange account states after relevant actions.

* feat: enhance trader creation readiness in AITradersPage and BeginnerGuideCards

---------

Co-authored-by: Dean <afei.wuhao@gmail.com>
2026-04-01 16:26:04 +08:00
shinchan-zhai
9937542020 docs: add MiniMax to AI models and beginner mode to setup across all i18n READMEs
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-31 22:16:46 +08:00
Zavier
287280857b perf: reduce frontend login and dashboard friction (#1447)
Co-authored-by: apple <apple@MacbookPro-zbh.local>
2026-03-31 20:40:12 +08:00
shinchan-zhai
d250aed26a fix: auto re-fetch system config after invalidation
- invalidateSystemConfig() now dispatches a custom event
- useSystemConfig() listens for the event and re-fetches automatically
- Fixes stale initialized=false after register/logout causing
  incorrect redirect to SetupPage
2026-03-31 16:12:01 +08:00
shinchan-zhai
608f02ed67 fix: clean stale auth state on login/setup, unify language switcher
- LoginPage/SetupPage: clear localStorage auth tokens on mount
- AuthContext: clear onboarding state on register, invalidate config on logout
- Extract shared LanguageSwitcher component for consistent UI
- Merge duplicate config import in AuthContext
2026-03-31 15:23:00 +08:00
deanokk
1d6e99c74a feat(beginner): protect default AI model and prevent repeated onboarding (#1444)
Co-authored-by: Dean <afei.wuhao@gmail.com>
2026-03-30 21:04:43 +08:00
shinchan-zhai
fb0bd13f51 fix: division by zero guard, logout redirect, onboarding close button
- auto_trader_risk: skip drawdown check when entryPrice <= 0
- AuthContext: redirect to / on logout
- App.tsx: simplify data page navigation
- BeginnerOnboardingPage: add close button to overlay
2026-03-30 14:02:50 +08:00
Zavier
55db747318 feat: refine beginner wallet onboarding modal (#1438)
Co-authored-by: Codex <codex@openai.com>
2026-03-28 16:09:04 +08:00
shinchan-zhai
cab58afe6d fix: guard short trader ID, i18n setup page, simplify onboarding UX
- main.go: prevent panic when trader ID < 8 chars
- SetupPage: add zh/en i18n labels
- BeginnerOnboardingPage: show private key by default, simplify code
2026-03-28 14:14:20 +08:00
shinchan-zhai
9176aa9844 fix(deps): resolve 11 npm vulnerabilities in frontend dependencies
Update react-router, rollup, picomatch, and yaml to patched versions.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-28 00:29:12 +08:00
Dean
7464dfa892 docs: update token estimation values for candidate coins in Chinese documentation 2026-03-28 00:23:11 +08:00
Dean
2e2598e4e0 fix: update token limits and error handling in Trader Dashboard 2026-03-28 00:23:11 +08:00
Dean
fbca4166a1 fix: reduce candidate coin limit to 10, fix Select scroll and flash
- Lower MaxCandidateCoins from 50 to 10 (backend)
- Update CoinSourceEditor: options 1-10, default 3, max static coins 10
- Fix NofxSelect dropdown closing on internal scroll
- Fix NofxSelect position flash on open (useLayoutEffect)
2026-03-28 00:23:11 +08:00
Dean
f83f2b1c18 style: apply gofmt to api/strategy.go and store/strategy.go 2026-03-28 00:23:11 +08:00
Dean
c6adc34247 fix: update error handling for account data fetch on Trader Dashboard 2026-03-28 00:23:11 +08:00
Dean
1d897f635e feat: localize default strategy names by UI language at registration
- Pass `lang` from register request body to createDefaultStrategies
- Support zh/en/id locales for strategy names and descriptions
- Wrap strategy creation in a transaction to prevent partial writes
- Frontend sends current UI language in register request body
- Strategy list UI: 2-line clamp, unselected border, larger spacing, smaller font for non-zh
2026-03-28 00:23:11 +08:00
Dean
39782600a9 docs: add token estimation analysis for candidate coin limits 2026-03-28 00:22:49 +08:00
Dean
1c378007ee fix: show -- instead of 0 when account data fetch fails on dashboard
Replace zero-value fallback with undefined, pass accountFailed prop to
distinguish load failure from initial loading skeleton.
2026-03-28 00:22:49 +08:00
Dean
b0be49569c feat: implement default strategy creation for new users 2026-03-28 00:22:49 +08:00
Dean
95e76f6a56 feat: enhance token estimation and context limit handling in strategy configurations 2026-03-28 00:22:49 +08:00