safehands-pharos 1.2.6 → 1.4.0
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/.env.example +64 -26
- package/README.md +333 -445
- package/dist/cli.d.ts +5 -5
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +124 -98
- package/dist/cli.js.map +1 -1
- package/dist/demo.d.ts +1 -1
- package/dist/demo.js +171 -171
- package/dist/index.d.ts +2 -2
- package/dist/index.js +138 -87
- package/dist/index.js.map +1 -1
- package/dist/init.d.ts +1 -1
- package/dist/init.js +65 -65
- package/dist/lib/auditLog.d.ts +9 -0
- package/dist/lib/auditLog.d.ts.map +1 -0
- package/dist/lib/auditLog.js +30 -0
- package/dist/lib/auditLog.js.map +1 -0
- package/dist/lib/constants.d.ts +291 -291
- package/dist/lib/constants.js +292 -292
- package/dist/lib/dodoApi.d.ts +78 -70
- package/dist/lib/dodoApi.d.ts.map +1 -1
- package/dist/lib/dodoApi.js +196 -178
- package/dist/lib/dodoApi.js.map +1 -1
- package/dist/lib/http.d.ts +14 -14
- package/dist/lib/http.js +118 -118
- package/dist/lib/pharosClient.d.ts +58 -58
- package/dist/lib/pharosClient.d.ts.map +1 -1
- package/dist/lib/pharosClient.js +63 -53
- package/dist/lib/pharosClient.js.map +1 -1
- package/dist/lib/policy/actionPolicyEngine.d.ts +53 -53
- package/dist/lib/policy/actionPolicyEngine.js +212 -212
- package/dist/lib/policy/actionPolicyEngine.js.map +1 -1
- package/dist/lib/riskEngine.d.ts +26 -26
- package/dist/lib/riskEngine.js +283 -283
- package/dist/lib/signer/index.d.ts +24 -24
- package/dist/lib/signer/index.d.ts.map +1 -1
- package/dist/lib/signer/index.js +88 -89
- package/dist/lib/signer/index.js.map +1 -1
- package/dist/lib/spendAccumulator.d.ts +10 -0
- package/dist/lib/spendAccumulator.d.ts.map +1 -0
- package/dist/lib/spendAccumulator.js +54 -0
- package/dist/lib/spendAccumulator.js.map +1 -0
- package/dist/lib/testDodoLive.d.ts +1 -1
- package/dist/lib/testDodoLive.js +104 -104
- package/dist/lib/testLiveSafehands.d.ts +1 -1
- package/dist/lib/testLiveSafehands.js +92 -92
- package/dist/lib/testRpc.d.ts +1 -1
- package/dist/lib/testRpc.js +29 -29
- package/dist/lib/testRpcLive.d.ts +1 -1
- package/dist/lib/testRpcLive.js +88 -88
- package/dist/lib/testTools.d.ts +1 -1
- package/dist/lib/testTools.js +397 -397
- package/dist/lib/testX402Live.d.ts +1 -1
- package/dist/lib/testX402Live.js +159 -159
- package/dist/lib/toolResponse.d.ts +25 -25
- package/dist/lib/toolResponse.js +53 -53
- package/dist/lib/wallet/index.d.ts +37 -18
- package/dist/lib/wallet/index.d.ts.map +1 -1
- package/dist/lib/wallet/index.js +128 -70
- package/dist/lib/wallet/index.js.map +1 -1
- package/dist/scripts/checkDeploy.d.ts +1 -1
- package/dist/scripts/checkDeploy.js +24 -24
- package/dist/scripts/deployRegistry.d.ts +1 -1
- package/dist/scripts/deployRegistry.js +100 -100
- package/dist/scripts/testRegistry.d.ts +1 -1
- package/dist/scripts/testRegistry.js +43 -43
- package/dist/tools/approveToken.d.ts +45 -46
- package/dist/tools/approveToken.d.ts.map +1 -1
- package/dist/tools/approveToken.js +85 -83
- package/dist/tools/approveToken.js.map +1 -1
- package/dist/tools/assessRisk.d.ts +79 -79
- package/dist/tools/assessRisk.d.ts.map +1 -1
- package/dist/tools/assessRisk.js +104 -93
- package/dist/tools/assessRisk.js.map +1 -1
- package/dist/tools/checkAllowance.d.ts +43 -36
- package/dist/tools/checkAllowance.d.ts.map +1 -1
- package/dist/tools/checkAllowance.js +56 -42
- package/dist/tools/checkAllowance.js.map +1 -1
- package/dist/tools/checkTokenSecurity.d.ts +46 -46
- package/dist/tools/checkTokenSecurity.d.ts.map +1 -1
- package/dist/tools/checkTokenSecurity.js +95 -88
- package/dist/tools/checkTokenSecurity.js.map +1 -1
- package/dist/tools/createAgentWallet.d.ts +26 -26
- package/dist/tools/createAgentWallet.d.ts.map +1 -1
- package/dist/tools/createAgentWallet.js +58 -59
- package/dist/tools/createAgentWallet.js.map +1 -1
- package/dist/tools/estimateGas.d.ts +79 -79
- package/dist/tools/estimateGas.js +124 -124
- package/dist/tools/executeSwap.d.ts +61 -59
- package/dist/tools/executeSwap.d.ts.map +1 -1
- package/dist/tools/executeSwap.js +141 -129
- package/dist/tools/executeSwap.js.map +1 -1
- package/dist/tools/explainRisk.d.ts +29 -29
- package/dist/tools/explainRisk.js +32 -32
- package/dist/tools/getAgentWallet.d.ts +21 -21
- package/dist/tools/getAgentWallet.js +27 -27
- package/dist/tools/getAgentWalletBalance.d.ts +11 -11
- package/dist/tools/getAgentWalletBalance.js +70 -70
- package/dist/tools/getExecutionHistory.d.ts +49 -51
- package/dist/tools/getExecutionHistory.d.ts.map +1 -1
- package/dist/tools/getExecutionHistory.js +154 -93
- package/dist/tools/getExecutionHistory.js.map +1 -1
- package/dist/tools/getGasPrice.d.ts +43 -43
- package/dist/tools/getGasPrice.js +59 -59
- package/dist/tools/getPoolInfo.d.ts +75 -75
- package/dist/tools/getPoolInfo.js +137 -137
- package/dist/tools/getTokenPrice.d.ts +113 -113
- package/dist/tools/getTokenPrice.js +117 -117
- package/dist/tools/getTransactionStatus.d.ts +43 -57
- package/dist/tools/getTransactionStatus.d.ts.map +1 -1
- package/dist/tools/getTransactionStatus.js +59 -67
- package/dist/tools/getTransactionStatus.js.map +1 -1
- package/dist/tools/getWalletBalance.d.ts +68 -68
- package/dist/tools/getWalletBalance.js +87 -87
- package/dist/tools/publishRiskScore.d.ts +63 -63
- package/dist/tools/publishRiskScore.d.ts.map +1 -1
- package/dist/tools/publishRiskScore.js +88 -85
- package/dist/tools/publishRiskScore.js.map +1 -1
- package/dist/tools/queryRiskRegistry.d.ts +38 -48
- package/dist/tools/queryRiskRegistry.d.ts.map +1 -1
- package/dist/tools/queryRiskRegistry.js +55 -60
- package/dist/tools/queryRiskRegistry.js.map +1 -1
- package/dist/tools/safehandsPreflightCheck.d.ts +77 -77
- package/dist/tools/safehandsPreflightCheck.js +47 -47
- package/dist/tools/safehandsRiskReport.d.ts +81 -81
- package/dist/tools/safehandsRiskReport.js +28 -28
- package/dist/tools/safehandsSafeExecute.d.ts +20 -20
- package/dist/tools/safehandsSafeExecute.d.ts.map +1 -1
- package/dist/tools/safehandsSafeExecute.js +81 -75
- package/dist/tools/safehandsSafeExecute.js.map +1 -1
- package/dist/tools/safehandsWalletHealth.d.ts +14 -14
- package/dist/tools/safehandsWalletHealth.js +103 -103
- package/dist/tools/safehandsX402Preflight.d.ts +26 -26
- package/dist/tools/safehandsX402Preflight.js +65 -65
- package/dist/tools/sendPayment.d.ts +57 -58
- package/dist/tools/sendPayment.d.ts.map +1 -1
- package/dist/tools/sendPayment.js +117 -108
- package/dist/tools/sendPayment.js.map +1 -1
- package/dist/tools/simulateTransaction.d.ts +60 -81
- package/dist/tools/simulateTransaction.d.ts.map +1 -1
- package/dist/tools/simulateTransaction.js +83 -88
- package/dist/tools/simulateTransaction.js.map +1 -1
- package/dist/tools/tokenRegistryStatus.d.ts +26 -26
- package/dist/tools/tokenRegistryStatus.js +96 -96
- package/dist/tools/x402PayAndFetch.d.ts +81 -81
- package/dist/tools/x402PayAndFetch.d.ts.map +1 -1
- package/dist/tools/x402PayAndFetch.js +152 -149
- package/dist/tools/x402PayAndFetch.js.map +1 -1
- package/dist/x402Server.d.ts +1 -1
- package/dist/x402Server.js +252 -252
- package/examples/dashboard/index.html +337 -0
- package/package.json +83 -82
- package/skill/SKILL.md +133 -133
package/skill/SKILL.md
CHANGED
|
@@ -1,133 +1,133 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: safehands-pharos-guard
|
|
3
|
-
description: >
|
|
4
|
-
REQUIRED before any Pharos AI agent write action involving token approvals, payments, swaps,
|
|
5
|
-
x402 paid requests, or custom contract calls. SafeHands runs policy-based preflight checks
|
|
6
|
-
and returns ALLOW, WARN, BLOCK, REQUIRE_CONFIRMATION, REQUIRE_FUNDING, or REQUIRE_TOKEN_REVIEW
|
|
7
|
-
before execution. Use this skill as a safety firewall before invoking Pharos Skill Engine
|
|
8
|
-
write operations.
|
|
9
|
-
version: 1.
|
|
10
|
-
requires:
|
|
11
|
-
anyBins:
|
|
12
|
-
- npx
|
|
13
|
-
---
|
|
14
|
-
|
|
15
|
-
# SafeHands Pharos Guard
|
|
16
|
-
|
|
17
|
-
Transaction Safety Firewall / Guardrail Skill for Pharos AI agents. SafeHands checks whether an action is safe before execution on Pharos Atlantic Testnet.
|
|
18
|
-
|
|
19
|
-
SafeHands complements the official `pharos-skill-engine`. It is not a replacement. The official Skill Engine provides general on-chain capabilities (queries, transactions, contract deployments). SafeHands answers: **"Is this action safe to execute?"**
|
|
20
|
-
|
|
21
|
-
```text
|
|
22
|
-
User intent
|
|
23
|
-
→ SafeHands preflight (ALLOW / WARN / BLOCK / REQUIRE_CONFIRMATION)
|
|
24
|
-
→ Pharos Skill Engine or MCP execution (only if safe)
|
|
25
|
-
→ SafeHands risk report
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
## Real-World Use Cases
|
|
29
|
-
|
|
30
|
-
1. **Anti-Drain Protection:** An AI Agent is tricked by a prompt injection to approve `999999 USDC` to a hacker's contract. SafeHands intercepts the action, detects an unlimited approval, and returns `BLOCK`.
|
|
31
|
-
2. **SSRF Payment Prevention:** A malicious website asks the AI Agent to pay `0.001 USDC` to an x402 URL pointing to `http://localhost:8080/admin`. SafeHands detects the private IP address, blocks the HTTP request, and returns `BLOCK` preventing server compromise.
|
|
32
|
-
3. **Fake Token Detection:** An AI Agent decides to buy a token named "Official Pharos Coin" on the testnet. SafeHands checks the `token_registry_status`, realizes it's a fake token not listed in the official docs, and returns `WARN` to ask the human for confirmation before swapping.
|
|
33
|
-
|
|
34
|
-
## Prerequisites
|
|
35
|
-
|
|
36
|
-
1. **Install SafeHands** (via npx, no global install required):
|
|
37
|
-
```bash
|
|
38
|
-
npx safehands-pharos --help
|
|
39
|
-
```
|
|
40
|
-
If `npx safehands-pharos` is not available, install globally:
|
|
41
|
-
```bash
|
|
42
|
-
npm install -g safehands-pharos
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
2. **No private key required** for safety checks. Private keys are only needed for write execution (which is disabled by default).
|
|
46
|
-
|
|
47
|
-
## Network Configuration
|
|
48
|
-
|
|
49
|
-
SafeHands reads network configuration from its built-in constants. Default network: **Atlantic Testnet**.
|
|
50
|
-
|
|
51
|
-
| Field | Value |
|
|
52
|
-
|-------|-------|
|
|
53
|
-
| Environment | `atlantic-testnet` |
|
|
54
|
-
| Chain ID | `688689` |
|
|
55
|
-
| RPC URL | `https://atlantic.dplabs-internal.com` |
|
|
56
|
-
| Native Token | `PHRS` |
|
|
57
|
-
| Primary USDC | `0xE0BE08c77f415F577A1B3A9aD7a1Df1479564ec8` |
|
|
58
|
-
| Mainnet | `false` |
|
|
59
|
-
|
|
60
|
-
Token addresses are sourced from the official Pharos Skill Engine `assets/tokens.json`.
|
|
61
|
-
|
|
62
|
-
## Safety Model
|
|
63
|
-
|
|
64
|
-
SafeHands enforces these guardrails by default:
|
|
65
|
-
|
|
66
|
-
- **Block** mainnet actions
|
|
67
|
-
- **Block** chain ID mismatch
|
|
68
|
-
- **Block** unlimited token approvals
|
|
69
|
-
- **Block** SSRF-sensitive x402 URLs (localhost, private IPs)
|
|
70
|
-
- **Block** payments above configured limits
|
|
71
|
-
- **Block** x402 payments above `MAX_X402_PAYMENT_USDC`
|
|
72
|
-
- **Warn** when token is custom or non-registry
|
|
73
|
-
- **Warn** when token security provider is unavailable
|
|
74
|
-
- **Require confirmation** for medium-risk actions
|
|
75
|
-
- **Allow** low-risk Pharos Atlantic Testnet actions
|
|
76
|
-
|
|
77
|
-
Write tools are disabled by default (`WRITE_TOOLS_ENABLED=false`).
|
|
78
|
-
|
|
79
|
-
## Capability Index
|
|
80
|
-
|
|
81
|
-
Load the corresponding reference file based on user needs to get full command templates.
|
|
82
|
-
|
|
83
|
-
| User Need | Capability | Detailed Instructions |
|
|
84
|
-
|-----------|------------|----------------------|
|
|
85
|
-
| Check whether an on-chain action is safe before execution | SafeHands Preflight Check | → `references/safehands.md#safehands-preflight-check` |
|
|
86
|
-
| Check whether an x402 paid endpoint is safe to pay | SafeHands x402 Preflight | → `references/safehands.md#safehands-x402-preflight` |
|
|
87
|
-
| Check whether an agent wallet is ready to act | SafeHands Wallet Health | → `references/safehands.md#safehands-wallet-health` |
|
|
88
|
-
| Check whether a token address is canonical or custom | Token Registry Status | → `references/safehands.md#token-registry-status` |
|
|
89
|
-
| Explain why an action was blocked or warned | Explain Risk | → `references/safehands.md#explain-risk` |
|
|
90
|
-
| Generate a human-readable safety report | SafeHands Risk Report | → `references/safehands.md#safehands-risk-report` |
|
|
91
|
-
|
|
92
|
-
## General Error Handling
|
|
93
|
-
|
|
94
|
-
Before executing commands, the Agent should perform pre-checks; when commands fail, provide user-friendly error messages based on the structured JSON output.
|
|
95
|
-
|
|
96
|
-
| Error Scenario | Error Code | Handling |
|
|
97
|
-
|---------------|-----------|----------|
|
|
98
|
-
| Invalid address format | `INVALID_TOKEN_ADDRESS` / `INVALID_WALLET_ADDRESS` | Prompt to check address format (0x + 40 hex characters) |
|
|
99
|
-
| Write tools disabled | `WRITE_TOOLS_DISABLED` | Inform user that write tools are disabled by default |
|
|
100
|
-
| SSRF blocked URL | `SSRF_BLOCKED` | Do not fetch or pay; inform user the URL is blocked |
|
|
101
|
-
| Mainnet action attempted | `MAINNET_NOT_SUPPORTED` | Do not execute; SafeHands is testnet-only |
|
|
102
|
-
| Chain ID mismatch | `CHAIN_ID_MISMATCH` | Switch to Pharos Atlantic Testnet (688689) |
|
|
103
|
-
| Signer not available | `NO_SIGNER_AVAILABLE` | Ask user to configure wallet mode |
|
|
104
|
-
| Invalid input JSON | `INVALID_INPUT_JSON` | Fix the JSON input and retry |
|
|
105
|
-
| Policy blocked | `POLICY_BLOCKED` | Explain reasons to the user; do not execute |
|
|
106
|
-
|
|
107
|
-
See `references/safehands.md` for detailed error handling tables for each operation.
|
|
108
|
-
|
|
109
|
-
## Security Reminders
|
|
110
|
-
|
|
111
|
-
- **No private key required** for read-only safety checks (preflight, token registry, wallet health, explain risk).
|
|
112
|
-
- **Write tools are disabled by default.** Set `WRITE_TOOLS_ENABLED=true` only for trusted testnet execution.
|
|
113
|
-
- **Private keys are never returned** in CLI or MCP responses.
|
|
114
|
-
- **Unlimited approvals are blocked** unless explicitly allowed via `ALLOW_UNLIMITED_APPROVAL=true`.
|
|
115
|
-
- **SSRF protection** blocks localhost and private IP x402 URLs by default.
|
|
116
|
-
- **Testnet only.** SafeHands is not audited for mainnet production use.
|
|
117
|
-
|
|
118
|
-
## Write Operation Pre-checks (Required for All Write Operations)
|
|
119
|
-
|
|
120
|
-
For all write operations, the Agent must run SafeHands preflight first:
|
|
121
|
-
|
|
122
|
-
```bash
|
|
123
|
-
npx safehands-pharos skill safehands_preflight_check --input-json '<action_json>'
|
|
124
|
-
```
|
|
125
|
-
|
|
126
|
-
1. If `decision` is `BLOCK`, **stop execution**.
|
|
127
|
-
2. If `decision` is `WARN`, explain the risk and ask for user confirmation.
|
|
128
|
-
3. If `decision` is `REQUIRE_CONFIRMATION`, ask for explicit user approval.
|
|
129
|
-
4. If `decision` is `REQUIRE_FUNDING`, ask user to fund the wallet.
|
|
130
|
-
5. If `decision` is `REQUIRE_TOKEN_REVIEW`, ask user to verify the token contract.
|
|
131
|
-
6. If `decision` is `ALLOW`, proceed with the Pharos Skill Engine write operation.
|
|
132
|
-
|
|
133
|
-
For full command templates, parameters, output parsing, and error handling, see [`references/safehands.md`](references/safehands.md).
|
|
1
|
+
---
|
|
2
|
+
name: safehands-pharos-guard
|
|
3
|
+
description: >
|
|
4
|
+
REQUIRED before any Pharos AI agent write action involving token approvals, payments, swaps,
|
|
5
|
+
x402 paid requests, or custom contract calls. SafeHands runs policy-based preflight checks
|
|
6
|
+
and returns ALLOW, WARN, BLOCK, REQUIRE_CONFIRMATION, REQUIRE_FUNDING, or REQUIRE_TOKEN_REVIEW
|
|
7
|
+
before execution. Use this skill as a safety firewall before invoking Pharos Skill Engine
|
|
8
|
+
write operations.
|
|
9
|
+
version: 1.3.0
|
|
10
|
+
requires:
|
|
11
|
+
anyBins:
|
|
12
|
+
- npx
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
# SafeHands Pharos Guard
|
|
16
|
+
|
|
17
|
+
Transaction Safety Firewall / Guardrail Skill for Pharos AI agents. SafeHands checks whether an action is safe before execution on Pharos Atlantic Testnet.
|
|
18
|
+
|
|
19
|
+
SafeHands complements the official `pharos-skill-engine`. It is not a replacement. The official Skill Engine provides general on-chain capabilities (queries, transactions, contract deployments). SafeHands answers: **"Is this action safe to execute?"**
|
|
20
|
+
|
|
21
|
+
```text
|
|
22
|
+
User intent
|
|
23
|
+
→ SafeHands preflight (ALLOW / WARN / BLOCK / REQUIRE_CONFIRMATION)
|
|
24
|
+
→ Pharos Skill Engine or MCP execution (only if safe)
|
|
25
|
+
→ SafeHands risk report
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Real-World Use Cases
|
|
29
|
+
|
|
30
|
+
1. **Anti-Drain Protection:** An AI Agent is tricked by a prompt injection to approve `999999 USDC` to a hacker's contract. SafeHands intercepts the action, detects an unlimited approval, and returns `BLOCK`.
|
|
31
|
+
2. **SSRF Payment Prevention:** A malicious website asks the AI Agent to pay `0.001 USDC` to an x402 URL pointing to `http://localhost:8080/admin`. SafeHands detects the private IP address, blocks the HTTP request, and returns `BLOCK` preventing server compromise.
|
|
32
|
+
3. **Fake Token Detection:** An AI Agent decides to buy a token named "Official Pharos Coin" on the testnet. SafeHands checks the `token_registry_status`, realizes it's a fake token not listed in the official docs, and returns `WARN` to ask the human for confirmation before swapping.
|
|
33
|
+
|
|
34
|
+
## Prerequisites
|
|
35
|
+
|
|
36
|
+
1. **Install SafeHands** (via npx, no global install required):
|
|
37
|
+
```bash
|
|
38
|
+
npx safehands-pharos --help
|
|
39
|
+
```
|
|
40
|
+
If `npx safehands-pharos` is not available, install globally:
|
|
41
|
+
```bash
|
|
42
|
+
npm install -g safehands-pharos
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
2. **No private key required** for safety checks. Private keys are only needed for write execution (which is disabled by default).
|
|
46
|
+
|
|
47
|
+
## Network Configuration
|
|
48
|
+
|
|
49
|
+
SafeHands reads network configuration from its built-in constants. Default network: **Atlantic Testnet**.
|
|
50
|
+
|
|
51
|
+
| Field | Value |
|
|
52
|
+
|-------|-------|
|
|
53
|
+
| Environment | `atlantic-testnet` |
|
|
54
|
+
| Chain ID | `688689` |
|
|
55
|
+
| RPC URL | `https://atlantic.dplabs-internal.com` |
|
|
56
|
+
| Native Token | `PHRS` |
|
|
57
|
+
| Primary USDC | `0xE0BE08c77f415F577A1B3A9aD7a1Df1479564ec8` |
|
|
58
|
+
| Mainnet | `false` |
|
|
59
|
+
|
|
60
|
+
Token addresses are sourced from the official Pharos Skill Engine `assets/tokens.json`.
|
|
61
|
+
|
|
62
|
+
## Safety Model
|
|
63
|
+
|
|
64
|
+
SafeHands enforces these guardrails by default:
|
|
65
|
+
|
|
66
|
+
- **Block** mainnet actions
|
|
67
|
+
- **Block** chain ID mismatch
|
|
68
|
+
- **Block** unlimited token approvals
|
|
69
|
+
- **Block** SSRF-sensitive x402 URLs (localhost, private IPs)
|
|
70
|
+
- **Block** payments above configured limits
|
|
71
|
+
- **Block** x402 payments above `MAX_X402_PAYMENT_USDC`
|
|
72
|
+
- **Warn** when token is custom or non-registry
|
|
73
|
+
- **Warn** when token security provider is unavailable
|
|
74
|
+
- **Require confirmation** for medium-risk actions
|
|
75
|
+
- **Allow** low-risk Pharos Atlantic Testnet actions
|
|
76
|
+
|
|
77
|
+
Write tools are disabled by default (`WRITE_TOOLS_ENABLED=false`).
|
|
78
|
+
|
|
79
|
+
## Capability Index
|
|
80
|
+
|
|
81
|
+
Load the corresponding reference file based on user needs to get full command templates.
|
|
82
|
+
|
|
83
|
+
| User Need | Capability | Detailed Instructions |
|
|
84
|
+
|-----------|------------|----------------------|
|
|
85
|
+
| Check whether an on-chain action is safe before execution | SafeHands Preflight Check | → `references/safehands.md#safehands-preflight-check` |
|
|
86
|
+
| Check whether an x402 paid endpoint is safe to pay | SafeHands x402 Preflight | → `references/safehands.md#safehands-x402-preflight` |
|
|
87
|
+
| Check whether an agent wallet is ready to act | SafeHands Wallet Health | → `references/safehands.md#safehands-wallet-health` |
|
|
88
|
+
| Check whether a token address is canonical or custom | Token Registry Status | → `references/safehands.md#token-registry-status` |
|
|
89
|
+
| Explain why an action was blocked or warned | Explain Risk | → `references/safehands.md#explain-risk` |
|
|
90
|
+
| Generate a human-readable safety report | SafeHands Risk Report | → `references/safehands.md#safehands-risk-report` |
|
|
91
|
+
|
|
92
|
+
## General Error Handling
|
|
93
|
+
|
|
94
|
+
Before executing commands, the Agent should perform pre-checks; when commands fail, provide user-friendly error messages based on the structured JSON output.
|
|
95
|
+
|
|
96
|
+
| Error Scenario | Error Code | Handling |
|
|
97
|
+
|---------------|-----------|----------|
|
|
98
|
+
| Invalid address format | `INVALID_TOKEN_ADDRESS` / `INVALID_WALLET_ADDRESS` | Prompt to check address format (0x + 40 hex characters) |
|
|
99
|
+
| Write tools disabled | `WRITE_TOOLS_DISABLED` | Inform user that write tools are disabled by default |
|
|
100
|
+
| SSRF blocked URL | `SSRF_BLOCKED` | Do not fetch or pay; inform user the URL is blocked |
|
|
101
|
+
| Mainnet action attempted | `MAINNET_NOT_SUPPORTED` | Do not execute; SafeHands is testnet-only |
|
|
102
|
+
| Chain ID mismatch | `CHAIN_ID_MISMATCH` | Switch to Pharos Atlantic Testnet (688689) |
|
|
103
|
+
| Signer not available | `NO_SIGNER_AVAILABLE` | Ask user to configure wallet mode |
|
|
104
|
+
| Invalid input JSON | `INVALID_INPUT_JSON` | Fix the JSON input and retry |
|
|
105
|
+
| Policy blocked | `POLICY_BLOCKED` | Explain reasons to the user; do not execute |
|
|
106
|
+
|
|
107
|
+
See `references/safehands.md` for detailed error handling tables for each operation.
|
|
108
|
+
|
|
109
|
+
## Security Reminders
|
|
110
|
+
|
|
111
|
+
- **No private key required** for read-only safety checks (preflight, token registry, wallet health, explain risk).
|
|
112
|
+
- **Write tools are disabled by default.** Set `WRITE_TOOLS_ENABLED=true` only for trusted testnet execution.
|
|
113
|
+
- **Private keys are never returned** in CLI or MCP responses.
|
|
114
|
+
- **Unlimited approvals are blocked** unless explicitly allowed via `ALLOW_UNLIMITED_APPROVAL=true`.
|
|
115
|
+
- **SSRF protection** blocks localhost and private IP x402 URLs by default.
|
|
116
|
+
- **Testnet only.** SafeHands is not audited for mainnet production use.
|
|
117
|
+
|
|
118
|
+
## Write Operation Pre-checks (Required for All Write Operations)
|
|
119
|
+
|
|
120
|
+
For all write operations, the Agent must run SafeHands preflight first:
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
npx safehands-pharos skill safehands_preflight_check --input-json '<action_json>'
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
1. If `decision` is `BLOCK`, **stop execution**.
|
|
127
|
+
2. If `decision` is `WARN`, explain the risk and ask for user confirmation.
|
|
128
|
+
3. If `decision` is `REQUIRE_CONFIRMATION`, ask for explicit user approval.
|
|
129
|
+
4. If `decision` is `REQUIRE_FUNDING`, ask user to fund the wallet.
|
|
130
|
+
5. If `decision` is `REQUIRE_TOKEN_REVIEW`, ask user to verify the token contract.
|
|
131
|
+
6. If `decision` is `ALLOW`, proceed with the Pharos Skill Engine write operation.
|
|
132
|
+
|
|
133
|
+
For full command templates, parameters, output parsing, and error handling, see [`references/safehands.md`](references/safehands.md).
|