@elizaos/plugin-waifu-swap-app 2.0.3-beta.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Shaw Walters and elizaOS Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,85 @@
1
+ # @elizaos/plugin-waifu-swap-app
2
+
3
+ Native **token-swap AppView** for waifu agents. Renders inside an agent's
4
+ ElizaOS web UI canvas (the apps overlay / desktop tab) and drives the
5
+ **PancakeSwap v3** swap capability on the waifu.fun API.
6
+
7
+ Phase of giving each waifu agent its own ElizaOS web UI: this replaces the
8
+ broken waifu patron swap panel (`apps/frontend/src/components/agent-home/wave-t/swap-panel.tsx`)
9
+ with a first-class app-plugin view, modeled on `plugin-hyperliquid-app` and
10
+ `plugin-waifu-imagegen-app`.
11
+
12
+ ## What it ships
13
+
14
+ - **`SwapAppView.tsx`** — token-in / token-out selectors, an amount input, a
15
+ reverse-direction control, a live quote (expected out + minimum received),
16
+ slippage presets, fee-tier selection, a route/price-impact detail strip, and a
17
+ swap CTA. Built on `@elizaos/app-core` primitives (`PagePanel`, `Button`,
18
+ `Spinner`) and `@elizaos/ui/agent-surface` (`useAgentElement`), matching the
19
+ visual + agent-addressability language of `plugin-hyperliquid-app`.
20
+ - **`swap-client.ts`** — auth-aware `POST` to
21
+ `/v2/agents/:token/capabilities/pancakeswap-v3/actions/:actionSlug` on the
22
+ waifu API (the generic capability-action route). Sends the agent-app invoke
23
+ key (`x-waifu-app-invoke-key`) when present, else a Steward JWT bearer. Maps
24
+ HTTP status onto typed `SwapError`s.
25
+ - **`swap-config.ts`** — resolves the waifu API base, agent token, auth
26
+ credential, and the swap-eligible token universe from a host-injected
27
+ `window.__WAIFU_SWAP__` global, `import.meta.env` (`VITE_WAIFU_*`), or a
28
+ production default. Always includes native BNB.
29
+ - **`swap-contracts.ts`** — standalone typed contract (capability/action slugs,
30
+ fee tiers, slippage bounds, token + quote shapes, local quote estimator, error
31
+ classifier). No waifu-monorepo imports. EVM `Address` defined locally.
32
+ - **`plugin.ts`** — the `views` declaration (`waifu-swap`) that
33
+ `plugin-app-manager` reads to discover + launch the view. Points at the
34
+ third-partyized bundle (`dist/views/bundle.js`) and the `SwapAppView` export.
35
+
36
+ ## Display-only vs execute
37
+
38
+ This view is **quote-only** today.
39
+
40
+ - **Quote / display — fully built.** The displayed quote is a transparent local
41
+ estimate (driven by per-token `priceBnb`), opportunistically upgraded with the
42
+ backend `quote` (read mode) action. Because the backend's `pancakeswap-v3:quote`
43
+ handler is **not yet registered** in the generic capability route's `HANDLERS`
44
+ map (it returns `501 NOT_IMPLEMENTED`), the local estimate stays the display
45
+ source until that lands; the client swallows the 501 and keeps the estimate.
46
+
47
+ - **Execute — intentionally stubbed (`SWAP_EXECUTE_TODO`).** The `swap` action is
48
+ `agent_signed` + `requiresConsent`, and likewise has no backend handler yet
49
+ (`501`). To avoid fabricating a money path, `executeSwap()` is gated behind
50
+ `SWAP_EXECUTE_ENABLED = false`: a confirmed press surfaces a clear
51
+ "execution not enabled yet" notice instead of POSTing to a route that can't
52
+ fulfil it. The typed `prepareSwap()` client + unsigned-tx contract are wired
53
+ and ready; flip `SWAP_EXECUTE_ENABLED` once the backend handler returns either
54
+ an unsigned tx (client-signed, the user signs in their own wallet) or an
55
+ agent-signer job, and the tx shape is confirmed.
56
+
57
+ **Follow-up to enable execution:** register `pancakeswap-v3:quote` and
58
+ `pancakeswap-v3:swap` handlers in
59
+ `apps/api/src/routes/v2/agents/capability-actions.ts` (`HANDLERS`), confirm the
60
+ unsigned-tx response shape, then flip `SWAP_EXECUTE_ENABLED` here.
61
+
62
+ ## Lazy + third-partyized
63
+
64
+ The overlay registration (`swap-app.ts`) loads the view via a dynamic
65
+ `import()`, and the view bundle third-partyizes `react`, `lucide-react`,
66
+ `@elizaos/ui`, and `@elizaos/app-core` (see `vite.config.views.ts`). The view's
67
+ component tree never lands in the main or mobile entry chunk.
68
+
69
+ ## Configuration
70
+
71
+ The host shell injects per-agent config when it mounts the view:
72
+
73
+ ```ts
74
+ window.__WAIFU_SWAP__ = {
75
+ apiBase: "https://waifu.fun",
76
+ agentTokenAddress: "0x…",
77
+ stewardJwt: "…", // OR appInvokeKey for trusted server surfaces
78
+ tokens: [ // swap-eligible universe (BNB is always added)
79
+ { address: "0x…", symbol: "SUKI", decimals: 18, priceBnb: 0.0001 },
80
+ ],
81
+ };
82
+ ```
83
+
84
+ Or via `import.meta.env`: `VITE_WAIFU_API_BASE`, `VITE_WAIFU_AGENT_TOKEN`,
85
+ `VITE_WAIFU_STEWARD_JWT`.
Binary file
package/package.json ADDED
@@ -0,0 +1,80 @@
1
+ {
2
+ "name": "@elizaos/plugin-waifu-swap-app",
3
+ "version": "2.0.3-beta.5",
4
+ "type": "module",
5
+ "main": "./dist/index.js",
6
+ "exports": {
7
+ ".": {
8
+ "types": "./dist/index.d.ts",
9
+ "eliza-source": {
10
+ "types": "./src/index.ts",
11
+ "import": "./src/index.ts",
12
+ "default": "./src/index.ts"
13
+ },
14
+ "import": "./dist/index.js",
15
+ "default": "./dist/index.js"
16
+ },
17
+ "./plugin": {
18
+ "types": "./dist/plugin.d.ts",
19
+ "import": "./dist/plugin.js",
20
+ "default": "./dist/plugin.js"
21
+ },
22
+ "./*.css": "./dist/*.css",
23
+ "./*": {
24
+ "types": "./dist/*.d.ts",
25
+ "eliza-source": {
26
+ "types": "./src/*.ts",
27
+ "import": "./src/*.ts",
28
+ "default": "./src/*.ts"
29
+ },
30
+ "import": "./dist/*.js",
31
+ "default": "./dist/*.js"
32
+ }
33
+ },
34
+ "dependencies": {
35
+ "@elizaos/app-core": "2.0.3-beta.5",
36
+ "@elizaos/core": "2.0.3-beta.5",
37
+ "@elizaos/shared": "2.0.3-beta.5",
38
+ "@elizaos/ui": "2.0.3-beta.5",
39
+ "lucide-react": "^1.0.0",
40
+ "react": "^19.0.0"
41
+ },
42
+ "elizaos": {
43
+ "app": {
44
+ "displayName": "Swap",
45
+ "category": "trading",
46
+ "heroImage": "assets/hero.png"
47
+ },
48
+ "appRegister": "register"
49
+ },
50
+ "publishConfig": {
51
+ "access": "public"
52
+ },
53
+ "types": "./dist/index.d.ts",
54
+ "scripts": {
55
+ "build": "bun run build:js && bun run build:views && bun run build:types",
56
+ "clean": "node ../../packages/scripts/rm-path-recursive.mjs dist",
57
+ "test": "vitest run --config vitest.config.ts",
58
+ "build:js": "tsup --config ../tsup.plugin-packages.shared.ts",
59
+ "build:views": "bunx --bun vite build --config vite.config.views.ts",
60
+ "build:types": "tsc --noCheck -p tsconfig.build.json",
61
+ "typecheck": "tsgo --noEmit -p tsconfig.build.json"
62
+ },
63
+ "files": [
64
+ "assets",
65
+ "dist"
66
+ ],
67
+ "devDependencies": {
68
+ "@testing-library/react": "^16.3.2",
69
+ "@types/react": "^19.0.0",
70
+ "@types/react-dom": "^19.0.0",
71
+ "jsdom": "^29.0.0",
72
+ "react": "^19.0.0",
73
+ "react-dom": "^19.0.0",
74
+ "tsup": "^8.5.1",
75
+ "typescript": "^6.0.3",
76
+ "vite": "^8.0.0",
77
+ "vitest": "^4.1.5"
78
+ },
79
+ "gitHead": "ff6157011c9459670021cc28a6797592a78b8817"
80
+ }