Skip to content

Commit cbda656

Browse files
committed
refactor: update companion app structure and policy presets
- Renamed script for starting the companion server in package.json. - Changed default port for the companion server from 4173 to 4174. - Removed obsolete public files (app.js, index.html) and related code. - Simplified policy presets to only include 'transfer' and 'custom', removing others. - Updated transfer policy structure to use 'target' and 'maxValuePerUse' instead of 'tokenAddress' and 'maxAmountBaseUnit'. - Adjusted validation and template structures to reflect the new policy format. - Enhanced error handling and response management in the handoff server. This commit streamlines the companion app's functionality and improves the policy management system.
1 parent 3405c35 commit cbda656

25 files changed

Lines changed: 1811 additions & 1275 deletions

companion/index.html

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<title>AGW Companion</title>
7+
<link rel="stylesheet" href="/public/styles.css" />
8+
</head>
9+
<body>
10+
<main class="shell">
11+
<header>
12+
<p class="eyebrow">Local Companion</p>
13+
<h1>AGW Companion</h1>
14+
<p class="subhead">Connect your wallet and create a session key for <code>agw-mcp</code>.</p>
15+
</header>
16+
17+
<!-- Step 1: Wallet Connection -->
18+
<section id="wallet-section" class="panel">
19+
<p class="eyebrow">Step 1 — Wallet</p>
20+
<p id="wallet-status" class="hint">Not connected</p>
21+
<button id="connect-wallet" type="button">Connect Wallet</button>
22+
</section>
23+
24+
<!-- Step 2: Policy Selection -->
25+
<section id="policy-section" class="panel" hidden>
26+
<p class="eyebrow">Step 2 — Session Policy</p>
27+
28+
<label for="policy-preset">Policy Preset</label>
29+
<select id="policy-preset" name="preset" required>
30+
<option value="transfer">Transfer (native ETH)</option>
31+
<option value="custom">Custom</option>
32+
</select>
33+
34+
<div id="custom-policy-field" class="custom-field" hidden>
35+
<label for="custom-policy">Custom Policy (JSON)</label>
36+
<textarea
37+
id="custom-policy"
38+
name="customPolicy"
39+
rows="10"
40+
spellcheck="false"
41+
placeholder='{"expiresInSeconds":900,"sessionConfig":{"feeLimit":"1000000000000000","maxValuePerUse":"1000000000000000","callPolicies":[],"transferPolicies":[]}}'
42+
></textarea>
43+
</div>
44+
</section>
45+
46+
<!-- Policy Preview -->
47+
<section id="preview-section" class="panel secondary" hidden>
48+
<p class="eyebrow">Policy Preview</p>
49+
<pre id="policy-preview"></pre>
50+
<p id="policy-risk-level" class="hint"></p>
51+
<ul id="policy-risk-reasons" class="risk-reasons"></ul>
52+
<label id="confirm-high-risk-wrapper" class="confirm-risk" hidden>
53+
<input id="confirm-high-risk" type="checkbox" />
54+
I confirm this high-risk policy and want to continue.
55+
</label>
56+
<p id="policy-preview-error" class="hint error" hidden></p>
57+
</section>
58+
59+
<!-- Step 3: Create Session -->
60+
<section id="session-section" class="panel" hidden>
61+
<p class="eyebrow">Step 3 — Create Session</p>
62+
<button id="create-session" type="button">Create Session Key</button>
63+
<p id="session-status" class="hint"></p>
64+
</section>
65+
66+
<!-- Result -->
67+
<section id="result-section" class="panel" hidden>
68+
<p class="eyebrow">Done</p>
69+
<p id="result-message" class="hint"></p>
70+
</section>
71+
</main>
72+
73+
<script type="module" src="/src/frontend/main.ts"></script>
74+
</body>
75+
</html>

companion/package.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"private": true,
3+
"type": "module",
4+
"scripts": {
5+
"dev": "vite",
6+
"build": "vite build",
7+
"preview": "vite preview"
8+
},
9+
"dependencies": {
10+
"@abstract-foundation/agw-client": "^1.10.0",
11+
"@abstract-foundation/agw-web": "^1.9.2",
12+
"buffer": "^6.0.3",
13+
"mipd": "^0.0.7",
14+
"viem": "^2"
15+
},
16+
"devDependencies": {
17+
"typescript": "^5.8.3",
18+
"vite": "^6"
19+
}
20+
}

0 commit comments

Comments
 (0)