You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Move duplicated logic (config, wallet, wallet-auth, keystore, API client)
into core/src/ so each interface is a thin presentation layer.
- core/src/config.ts: path resolution and env vars
- core/src/wallet.ts: read/write wallet.json with atomic writes
- core/src/wallet-auth.ts: EIP-191 signing via @noble/curves
- core/src/keystore.ts: unified object-based keystore with auto-migration
from legacy array format and expires_at → lease_expires_at rename
- core/src/client.ts: apiRequest() fetch wrapper
MCP src/ files become thin re-exports from core. CLI config.mjs imports
from core with process.exit wrappers. OpenClaw scripts become one-line
re-exports from CLI modules (-1,771 lines). Shared paid-fetch.mjs
deduplicates x402 payment setup across tier and image commands.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
-**`index.ts`** — Entry point. Registers all tools via `McpServer`.
73
+
-**`tools/*.ts`** — Each tool exports a Zod schema + async handler
74
+
75
+
### CLI (`cli/`)
76
+
77
+
-**`cli/lib/config.mjs`** — Imports from `core/dist/`, adds CLI wrappers (`walletAuthHeaders()` with process.exit, `findProject()` with process.exit). Re-exports core keystore functions.
78
+
-**`cli/lib/paid-fetch.mjs`** — Shared `setupPaidFetch()` using viem + @x402/fetch for paid endpoints.
79
+
-**`cli/lib/*.mjs`** — Each module exports `async run(sub, args)` with CLI output format.
80
+
81
+
### OpenClaw (`openclaw/`)
50
82
51
-
-**`index.ts`** — Entry point. Creates the `McpServer`, registers all tools with their Zod schemas and handlers, connects via `StdioServerTransport`.
52
-
-**`client.ts`** — Single `apiRequest()` function wrapping `fetch()` against `RUN402_API_BASE`. Handles JSON/text responses and identifies 402 (payment required) responses with `is402` flag.
53
-
-**`config.ts`** — Reads `RUN402_API_BASE` (default `https://api.run402.com`) and `RUN402_CONFIG_DIR` (default `~/.config/run402`) from env.
54
-
-**`keystore.ts`** — Atomic file-based credential store at `~/.config/run402/projects.json` (mode 0600). Uses temp-file + rename for safe writes.
83
+
-**`openclaw/scripts/config.mjs`** — Re-exports from `cli/lib/config.mjs`
84
+
-**`openclaw/scripts/*.mjs`** — Thin shims: `export { run } from "../../cli/lib/<name>.mjs"`
85
+
-**`openclaw/scripts/init.mjs`** — Calls CLI's `run()` at top level (executable script)
0 commit comments