safehands-pharos 1.3.0 → 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.
Files changed (159) hide show
  1. package/.env.example +64 -26
  2. package/README.md +333 -445
  3. package/dist/cli.d.ts +5 -5
  4. package/dist/cli.d.ts.map +1 -1
  5. package/dist/cli.js +124 -98
  6. package/dist/cli.js.map +1 -1
  7. package/dist/demo.d.ts +1 -1
  8. package/dist/demo.js +171 -171
  9. package/dist/index.d.ts +2 -2
  10. package/dist/index.js +138 -85
  11. package/dist/index.js.map +1 -1
  12. package/dist/init.d.ts +1 -1
  13. package/dist/init.js +65 -65
  14. package/dist/lib/auditLog.d.ts +9 -0
  15. package/dist/lib/auditLog.d.ts.map +1 -0
  16. package/dist/lib/auditLog.js +30 -0
  17. package/dist/lib/auditLog.js.map +1 -0
  18. package/dist/lib/constants.d.ts +291 -291
  19. package/dist/lib/constants.js +292 -292
  20. package/dist/lib/dodoApi.d.ts +78 -70
  21. package/dist/lib/dodoApi.d.ts.map +1 -1
  22. package/dist/lib/dodoApi.js +196 -178
  23. package/dist/lib/dodoApi.js.map +1 -1
  24. package/dist/lib/http.d.ts +14 -14
  25. package/dist/lib/http.js +118 -118
  26. package/dist/lib/pharosClient.d.ts +58 -58
  27. package/dist/lib/pharosClient.d.ts.map +1 -1
  28. package/dist/lib/pharosClient.js +63 -53
  29. package/dist/lib/pharosClient.js.map +1 -1
  30. package/dist/lib/policy/actionPolicyEngine.d.ts +53 -53
  31. package/dist/lib/policy/actionPolicyEngine.js +212 -212
  32. package/dist/lib/riskEngine.d.ts +26 -26
  33. package/dist/lib/riskEngine.js +283 -283
  34. package/dist/lib/signer/index.d.ts +24 -24
  35. package/dist/lib/signer/index.d.ts.map +1 -1
  36. package/dist/lib/signer/index.js +88 -89
  37. package/dist/lib/signer/index.js.map +1 -1
  38. package/dist/lib/spendAccumulator.d.ts +10 -0
  39. package/dist/lib/spendAccumulator.d.ts.map +1 -0
  40. package/dist/lib/spendAccumulator.js +54 -0
  41. package/dist/lib/spendAccumulator.js.map +1 -0
  42. package/dist/lib/testDodoLive.d.ts +1 -1
  43. package/dist/lib/testDodoLive.js +104 -104
  44. package/dist/lib/testLiveSafehands.d.ts +1 -1
  45. package/dist/lib/testLiveSafehands.js +92 -92
  46. package/dist/lib/testRpc.d.ts +1 -1
  47. package/dist/lib/testRpc.js +29 -29
  48. package/dist/lib/testRpcLive.d.ts +1 -1
  49. package/dist/lib/testRpcLive.js +88 -88
  50. package/dist/lib/testTools.d.ts +1 -1
  51. package/dist/lib/testTools.js +397 -397
  52. package/dist/lib/testX402Live.d.ts +1 -1
  53. package/dist/lib/testX402Live.js +159 -159
  54. package/dist/lib/toolResponse.d.ts +25 -25
  55. package/dist/lib/toolResponse.js +53 -53
  56. package/dist/lib/wallet/index.d.ts +37 -18
  57. package/dist/lib/wallet/index.d.ts.map +1 -1
  58. package/dist/lib/wallet/index.js +128 -70
  59. package/dist/lib/wallet/index.js.map +1 -1
  60. package/dist/scripts/checkDeploy.d.ts +1 -1
  61. package/dist/scripts/checkDeploy.js +24 -24
  62. package/dist/scripts/deployRegistry.d.ts +1 -1
  63. package/dist/scripts/deployRegistry.js +100 -100
  64. package/dist/scripts/testRegistry.d.ts +1 -1
  65. package/dist/scripts/testRegistry.js +43 -43
  66. package/dist/tools/approveToken.d.ts +45 -46
  67. package/dist/tools/approveToken.d.ts.map +1 -1
  68. package/dist/tools/approveToken.js +85 -83
  69. package/dist/tools/approveToken.js.map +1 -1
  70. package/dist/tools/assessRisk.d.ts +79 -79
  71. package/dist/tools/assessRisk.d.ts.map +1 -1
  72. package/dist/tools/assessRisk.js +104 -93
  73. package/dist/tools/assessRisk.js.map +1 -1
  74. package/dist/tools/checkAllowance.d.ts +43 -36
  75. package/dist/tools/checkAllowance.d.ts.map +1 -1
  76. package/dist/tools/checkAllowance.js +56 -42
  77. package/dist/tools/checkAllowance.js.map +1 -1
  78. package/dist/tools/checkTokenSecurity.d.ts +46 -46
  79. package/dist/tools/checkTokenSecurity.d.ts.map +1 -1
  80. package/dist/tools/checkTokenSecurity.js +95 -88
  81. package/dist/tools/checkTokenSecurity.js.map +1 -1
  82. package/dist/tools/createAgentWallet.d.ts +26 -26
  83. package/dist/tools/createAgentWallet.d.ts.map +1 -1
  84. package/dist/tools/createAgentWallet.js +58 -59
  85. package/dist/tools/createAgentWallet.js.map +1 -1
  86. package/dist/tools/estimateGas.d.ts +79 -79
  87. package/dist/tools/estimateGas.js +124 -124
  88. package/dist/tools/executeSwap.d.ts +61 -59
  89. package/dist/tools/executeSwap.d.ts.map +1 -1
  90. package/dist/tools/executeSwap.js +141 -129
  91. package/dist/tools/executeSwap.js.map +1 -1
  92. package/dist/tools/explainRisk.d.ts +29 -29
  93. package/dist/tools/explainRisk.js +32 -32
  94. package/dist/tools/getAgentWallet.d.ts +21 -21
  95. package/dist/tools/getAgentWallet.js +27 -27
  96. package/dist/tools/getAgentWalletBalance.d.ts +11 -11
  97. package/dist/tools/getAgentWalletBalance.js +70 -70
  98. package/dist/tools/getExecutionHistory.d.ts +49 -51
  99. package/dist/tools/getExecutionHistory.d.ts.map +1 -1
  100. package/dist/tools/getExecutionHistory.js +154 -93
  101. package/dist/tools/getExecutionHistory.js.map +1 -1
  102. package/dist/tools/getGasPrice.d.ts +43 -43
  103. package/dist/tools/getGasPrice.js +59 -59
  104. package/dist/tools/getPoolInfo.d.ts +75 -75
  105. package/dist/tools/getPoolInfo.js +137 -137
  106. package/dist/tools/getTokenPrice.d.ts +113 -113
  107. package/dist/tools/getTokenPrice.js +117 -117
  108. package/dist/tools/getTransactionStatus.d.ts +43 -57
  109. package/dist/tools/getTransactionStatus.d.ts.map +1 -1
  110. package/dist/tools/getTransactionStatus.js +59 -67
  111. package/dist/tools/getTransactionStatus.js.map +1 -1
  112. package/dist/tools/getWalletBalance.d.ts +68 -68
  113. package/dist/tools/getWalletBalance.js +87 -87
  114. package/dist/tools/publishRiskScore.d.ts +63 -63
  115. package/dist/tools/publishRiskScore.d.ts.map +1 -1
  116. package/dist/tools/publishRiskScore.js +88 -85
  117. package/dist/tools/publishRiskScore.js.map +1 -1
  118. package/dist/tools/queryRiskRegistry.d.ts +38 -48
  119. package/dist/tools/queryRiskRegistry.d.ts.map +1 -1
  120. package/dist/tools/queryRiskRegistry.js +55 -60
  121. package/dist/tools/queryRiskRegistry.js.map +1 -1
  122. package/dist/tools/safehandsPreflightCheck.d.ts +77 -77
  123. package/dist/tools/safehandsPreflightCheck.js +47 -47
  124. package/dist/tools/safehandsRiskReport.d.ts +81 -81
  125. package/dist/tools/safehandsRiskReport.js +28 -28
  126. package/dist/tools/safehandsSafeExecute.d.ts +20 -20
  127. package/dist/tools/safehandsSafeExecute.d.ts.map +1 -1
  128. package/dist/tools/safehandsSafeExecute.js +81 -75
  129. package/dist/tools/safehandsSafeExecute.js.map +1 -1
  130. package/dist/tools/safehandsWalletHealth.d.ts +14 -14
  131. package/dist/tools/safehandsWalletHealth.js +103 -103
  132. package/dist/tools/safehandsX402Preflight.d.ts +26 -26
  133. package/dist/tools/safehandsX402Preflight.js +65 -65
  134. package/dist/tools/sendPayment.d.ts +57 -58
  135. package/dist/tools/sendPayment.d.ts.map +1 -1
  136. package/dist/tools/sendPayment.js +117 -108
  137. package/dist/tools/sendPayment.js.map +1 -1
  138. package/dist/tools/simulateTransaction.d.ts +60 -81
  139. package/dist/tools/simulateTransaction.d.ts.map +1 -1
  140. package/dist/tools/simulateTransaction.js +83 -88
  141. package/dist/tools/simulateTransaction.js.map +1 -1
  142. package/dist/tools/tokenRegistryStatus.d.ts +26 -26
  143. package/dist/tools/tokenRegistryStatus.js +96 -96
  144. package/dist/tools/x402PayAndFetch.d.ts +81 -81
  145. package/dist/tools/x402PayAndFetch.d.ts.map +1 -1
  146. package/dist/tools/x402PayAndFetch.js +152 -149
  147. package/dist/tools/x402PayAndFetch.js.map +1 -1
  148. package/dist/x402Server.d.ts +1 -1
  149. package/dist/x402Server.js +252 -252
  150. package/examples/dashboard/index.html +337 -0
  151. package/package.json +83 -84
  152. package/.agents/skill/safehands/SKILL.md +0 -212
  153. package/.agents/skill/safehands/assets/networks.json +0 -24
  154. package/.agents/skill/safehands/assets/tokens.json +0 -66
  155. package/.agents/wallets.json +0 -20
  156. package/docs/reports/OFFICIAL_DOCS_ALIGNMENT_REPORT.md +0 -137
  157. package/docs/reports/final_audit_report.md +0 -307
  158. package/docs/reports/live_verification_report.md +0 -147
  159. package/docs/reports/pharos_skill_engine_alignment_report.md +0 -85
@@ -1,307 +0,0 @@
1
- # SafeHands-Pharos Final Audit Report
2
-
3
- **Date:** 2026-06-12
4
- **Reviewer Roles:** Senior TypeScript Backend Engineer, MCP Architect, Pharos Skill Engine Integrator, Web3 Security Auditor, Hackathon Submission Reviewer
5
- **Repository:** safehands-pharos-main v1.2.0
6
-
7
- ---
8
-
9
- ## 1. Executive Summary
10
-
11
- SafeHands-Pharos is a **Pharos Skill Engine-compatible MCP package** that acts as a **Transaction Safety Firewall for AI agents**. It provides policy-based preflight checks before payment, token approval, swap, or x402 paid requests, returning `ALLOW`, `WARN`, or `BLOCK` decisions with human-readable risk explanations.
12
-
13
- The project builds cleanly, typechecks without errors, passes all 37/37 smoke tests, has zero high-level production vulnerabilities, produces a safe npm tarball, runs a deterministic demo without broadcasting transactions, and includes a complete Pharos Skill Engine adapter.
14
-
15
- **One minor fix was applied during this audit:** The `--demo` flag in the compiled entrypoint now uses `setTimeout(() => process.exit(0), 100)` instead of synchronous `process.exit(0)` to prevent a Windows-specific libuv `UV_HANDLE_CLOSING` assertion crash caused by express keep-alive sockets being closed during `process.exit`.
16
-
17
- ---
18
-
19
- ## 2. Does the App Work Like I Want?
20
-
21
- **Yes.** The app behaves as specified:
22
-
23
- | Behavior | Status |
24
- |---|---|
25
- | Preflight returns ALLOW for safe testnet actions | ✅ Verified |
26
- | Preflight returns BLOCK for mainnet actions | ✅ Verified |
27
- | Preflight returns BLOCK for unlimited approvals | ✅ Verified |
28
- | Preflight returns BLOCK for chain ID mismatch | ✅ Verified by code review |
29
- | SSRF-sensitive x402 URLs are blocked | ✅ Verified |
30
- | x402 free endpoints work without private key | ✅ Verified |
31
- | x402 paid endpoint returns structured signer error | ✅ Verified |
32
- | Write tools are disabled by default | ✅ Verified |
33
- | No wallet created on startup/import/install | ✅ Verified |
34
- | Demo runs deterministically without broadcasting | ✅ Verified |
35
- | CLI returns valid JSON envelope | ✅ Verified |
36
- | MCP server starts and registers 27 tools | ✅ Verified |
37
- | npm pack excludes all secrets | ✅ Verified |
38
-
39
- ---
40
-
41
- ## 3. Evidence from Code
42
-
43
- ### Policy Engine — Action Types
44
-
45
- All 6 action types are defined as a union type in [actionPolicyEngine.ts:L19-25](file:///c:/Users/Administrator/Desktop/safehands-pharos-main/src/lib/policy/actionPolicyEngine.ts#L19-L25):
46
-
47
- ```typescript
48
- export type SafeHandsActionType =
49
- | "send_payment"
50
- | "approve_token"
51
- | "execute_swap"
52
- | "x402_pay_and_fetch"
53
- | "publish_risk_score"
54
- | "custom_contract_call";
55
- ```
56
-
57
- ### Policy Engine — Decisions
58
-
59
- All 6 decisions are defined in [actionPolicyEngine.ts:L27-33](file:///c:/Users/Administrator/Desktop/safehands-pharos-main/src/lib/policy/actionPolicyEngine.ts#L27-L33):
60
-
61
- ```typescript
62
- export type PolicyDecision =
63
- | "ALLOW"
64
- | "WARN"
65
- | "BLOCK"
66
- | "REQUIRE_CONFIRMATION"
67
- | "REQUIRE_FUNDING"
68
- | "REQUIRE_TOKEN_REVIEW";
69
- ```
70
-
71
- ### Policy Engine — Risk Levels
72
-
73
- All 5 risk levels are defined in [actionPolicyEngine.ts:L35](file:///c:/Users/Administrator/Desktop/safehands-pharos-main/src/lib/policy/actionPolicyEngine.ts#L35):
74
-
75
- ```typescript
76
- export type PolicyRiskLevel = "LOW" | "MEDIUM" | "HIGH" | "CRITICAL" | "UNKNOWN";
77
- ```
78
-
79
- ### Policy Rule Implementation Evidence
80
-
81
- | Rule | File | Line(s) | Implementation |
82
- |---|---|---|---|
83
- | Block mainnet actions | `actionPolicyEngine.ts` | 162-166 | `if (isMainnet)` → `pushCheck("fail", ...)` |
84
- | Block chain ID mismatch | `actionPolicyEngine.ts` | 168-172 | `if (chainId !== CHAIN_ID)` → `pushCheck("fail", ...)` |
85
- | Block unlimited approval by default | `actionPolicyEngine.ts` | 198-209 | `isUnlimitedApprovalAmount()` check, blocked unless `allowUnlimitedApproval === true` |
86
- | Block SSRF-sensitive x402 URLs | `actionPolicyEngine.ts` | 118-134 | `isSuspiciousUrl()` blocks localhost, 127.x, 10.x, 172.16-31.x, 192.168.x, ::1 |
87
- | Block payment above configured limit | `actionPolicyEngine.ts` | 184-196 | `amount > MAX_TX_AMOUNT_PHRS` → fail |
88
- | Block x402 payment above MAX_X402_PAYMENT_USDC | `actionPolicyEngine.ts` | 231-236 | `payment > MAX_X402_PAYMENT_USDC` → fail |
89
- | Block approval above MAX_APPROVAL_AMOUNT_USDC | `actionPolicyEngine.ts` | 203-208 | `approvalAmount > MAX_APPROVAL_AMOUNT_USDC` → fail |
90
- | Warn if token security provider unavailable | `actionPolicyEngine.ts` | 257-258 | `tokenSecurityStatus === "unavailable"` → warn |
91
- | Warn if token is custom/non-registry | `actionPolicyEngine.ts` | 254-256 | `tokenRegistryStatus === "CUSTOM_NON_REGISTRY"` → warn |
92
- | Warn if recipient/spender is unverified | `actionPolicyEngine.ts` | 193-194, 212-213 | `recipientVerified === false` or `spenderVerified === false` → warn |
93
- | Require confirmation for medium-risk | `actionPolicyEngine.ts` | 149 | `if (riskLevel === "MEDIUM") return "REQUIRE_CONFIRMATION"` |
94
- | Allow low-risk Pharos Atlantic Testnet action | `actionPolicyEngine.ts` | 151 | `return "ALLOW"` when all checks pass |
95
-
96
- ### SSRF Implementation
97
-
98
- Full SSRF protection is in [http.ts:L85-145](file:///c:/Users/Administrator/Desktop/safehands-pharos-main/src/lib/http.ts#L85-L145):
99
- - IPv4 CIDR checks for `0.0.0.0/8`, `10.0.0.0/8`, `127.0.0.0/8`, `169.254.0.0/16`, `172.16.0.0/12`, `192.168.0.0/16`
100
- - IPv6 checks for `::1`, `fc`, `fd`, `fe80:`, `::ffff:127.*`, `::ffff:10.*`, `::ffff:192.168.*`
101
- - DNS resolution check to prevent TOCTOU bypass
102
-
103
- ### Private Key Isolation
104
-
105
- `process.env.PRIVATE_KEY` appears in exactly **one** file outside test code: [signer/index.ts](file:///c:/Users/Administrator/Desktop/safehands-pharos-main/src/lib/signer/index.ts). No tool handler reads it directly.
106
-
107
- ### x402 Payment Header Redaction
108
-
109
- In [x402PayAndFetch.ts:L155-159](file:///c:/Users/Administrator/Desktop/safehands-pharos-main/src/tools/x402PayAndFetch.ts#L155-L159), the `PAYMENT-RESPONSE` header is explicitly redacted:
110
- ```typescript
111
- paymentDetails: paymentResponseHeader
112
- ? { headerRedacted: true, note: "PAYMENT-RESPONSE header was present but intentionally not exposed..." }
113
- : null,
114
- ```
115
-
116
- ---
117
-
118
- ## 4. Evidence from Commands
119
-
120
- | Command | Result | Exit Code |
121
- |---|---|---|
122
- | `npm ci` | 139 packages installed, audited 140 | 0 |
123
- | `npm run build` | `tsc` compiled cleanly | 0 |
124
- | `npx tsc -p tsconfig.all.json --pretty false` | No errors | 0 |
125
- | `npm run test:all` | **37/37 smoke checks passed** | 0 |
126
- | `npm audit --omit=dev --audit-level=high` | **0 vulnerabilities** | 0 |
127
- | `npm pack --dry-run` | 194 files, 120.7 kB package | 0 |
128
- | `npm run demo` | Full 10-step demo completed | 0 |
129
- | `node dist/index.js --help` | Full branded help output | 0 |
130
- | `node dist/index.js --demo` | Full demo, clean exit | 0 |
131
- | `node dist/index.js skill safehands_wallet_health --input-json '{}'` | Valid JSON, `NOT_READY` status | 0 |
132
- | `node dist/index.js skill token_registry_status --input-json '...'` | `CANONICAL_TESTNET_TOKEN`, `DOCS_VERIFIED` | 0 |
133
- | `node dist/index.js skill safehands_preflight_check --input-json '...'` (unlimited approval) | `BLOCK`, `HIGH` risk | 0 |
134
- | `node dist/index.js` (MCP server) | Started on stdio, registered 27 tools | Ran successfully |
135
-
136
- ---
137
-
138
- ## 5. Official Docs Alignment Table
139
-
140
- | Item | Project Value | Official Docs Value | Status | Notes |
141
- |---|---|---|---|---|
142
- | Pharos environment | `atlantic-testnet` | `atlantic-testnet` | DOCS_VERIFIED | Matches Pharos Hardhat guide |
143
- | Chain ID | `688689` | `688689` | DOCS_VERIFIED | Matches Pharos Hardhat guide |
144
- | RPC URL | `https://atlantic.dplabs-internal.com` | `https://atlantic.dplabs-internal.com` | DOCS_VERIFIED | Matches Pharos Hardhat guide |
145
- | Primary USDC | `0xE0BE08c77f415F577A1B3A9aD7a1Df1479564ec8` | Pharos Skill Engine `tokens.json` | DOCS_VERIFIED_FROM_PHAROS_SKILL_ENGINE | Skill Engine canonical USDC |
146
- | Alternate USDC (Circle) | `0xcfC8330f4BCAB529c625D12781b1C19466A9Fc8B` | Circle Pharos Testnet USDC | CIRCLE_REFERENCED_USDC | Matches Circle USDC contract address docs but not Skill Engine primary |
147
- | x402 free endpoint behavior | No private key required for `/supported`, `/health` | Pharos x402 docs | DOCS_VERIFIED | Code and demo confirm free endpoints work without signer |
148
- | x402 paid endpoint behavior | Returns structured `X402_PAYMENT_REQUIRED` error when signer is absent | Expected x402 protocol behavior | DOCS_VERIFIED | Correctly returns `NO_SIGNER_AVAILABLE` |
149
- | Skill Engine structure | `SKILL.safehands.md`, `references/`, `assets/` | Pharos Skill Engine guide structure | DOCS_VERIFIED | Follows expected skill package layout |
150
- | FaroSwap/DODO router addresses | `0x4Cf...`, `0x819...` | Not independently verified from official Pharos docs | PROJECT_CONFIGURED | Labeled as project constants in code; used only when DODO_API_KEY is set |
151
- | USDT address | `0xE7E8...` | Not independently verified | PROJECT_CONFIGURED | Labeled `TODO verify against official docs` in source |
152
- | WBTC/WETH/WPHRS addresses | Various | Not independently verified | PROJECT_CONFIGURED | Labeled `TODO verify against official docs` in source |
153
- | RiskRegistry address | `0x71fc...` | Project-deployed contract | PROJECT_CONFIGURED | Deployed by project; not a Pharos official contract |
154
- | Testnet-only disclaimer | Present in README, SECURITY, HACKATHON_SUBMISSION, CLI help | N/A | DOCS_VERIFIED | Clearly stated in all relevant docs |
155
- | Mainnet support | Not claimed | N/A | DOCS_VERIFIED | `IS_MAINNET = false` hardcoded; all docs say testnet-only |
156
-
157
- > [!NOTE]
158
- > No CONFLICT status found. FaroSwap/DODO router addresses and some token addresses are honestly labeled as `PROJECT_CONFIGURED` in the source code with TODO notes for future verification.
159
-
160
- ---
161
-
162
- ## 6. MCP Status
163
-
164
- | Check | Result |
165
- |---|---|
166
- | MCP server starts | ✅ Yes |
167
- | Registered tools count | **27** (7 SafeHands branded + 17 core/legacy + 3 managed wallet) |
168
- | SafeHands branded tools present | ✅ All 7: `safehands_preflight_check`, `safehands_safe_execute`, `safehands_wallet_health`, `safehands_x402_preflight`, `safehands_risk_report`, `explain_risk`, `token_registry_status` |
169
- | Startup side effects | Only stderr warning about write tools being disabled |
170
- | Wallet created on startup | ✅ No |
171
- | Private key required on startup | ✅ No |
172
-
173
- ---
174
-
175
- ## 7. CLI Status
176
-
177
- | CLI Command | Result |
178
- |---|---|
179
- | `--help` | ✅ Shows branded help text with all 7 SafeHands tools, 20 other tools, testnet config, x402 behavior, safety defaults, and examples |
180
- | `--demo` | ✅ Runs all 10 demo sections deterministically with clean exit (code 0) |
181
- | `skill safehands_wallet_health --input-json '{}'` | ✅ Returns valid JSON: `NOT_READY` status, no private key required |
182
- | `skill token_registry_status --input-json '...'` | ✅ Returns `CANONICAL_TESTNET_TOKEN` with `DOCS_VERIFIED` |
183
- | `skill safehands_preflight_check --input-json '...'` (unlimited) | ✅ Returns `BLOCK`, `HIGH` risk, `"Unlimited approval requested."` |
184
- | Invalid JSON input | ✅ Returns `INVALID_INPUT_JSON` structured error |
185
- | Unknown tool name | ✅ Returns `UNKNOWN_SKILL_TOOL` structured error |
186
-
187
- ---
188
-
189
- ## 8. Skill Engine Adapter Status
190
-
191
- ### Structure
192
-
193
- ```
194
- examples/pharos-skill-engine/
195
- ├── SKILL.safehands.md ✅ 86 lines, complete
196
- ├── references/
197
- │ └── safehands.md ✅ 346 lines, complete
198
- └── assets/
199
- └── safehands/
200
- ├── policy-defaults.json ✅ 12 lines, matches .env.example
201
- └── example-actions.json ✅ 50 lines, 7 example actions
202
- ```
203
-
204
- ### Agent Usability Assessment
205
-
206
- | Question | Answer |
207
- |---|---|
208
- | Can an AI agent understand when to use SafeHands? | ✅ Yes — "When to use" and "When not to use" sections are clear |
209
- | Can an AI agent know which CLI command to run? | ✅ Yes — Command templates with full `npx` syntax in every reference section |
210
- | Can an AI agent parse the response? | ✅ Yes — Output parsing tables for every tool with field-by-field meaning |
211
- | Are BLOCK/WARN/ALLOW behaviors explained? | ✅ Yes — Agent guidelines in SKILL.md (10 rules) and per-tool sections |
212
- | Are error-handling steps explained? | ✅ Yes — Error tables with code, meaning, and agent action for each tool |
213
-
214
- ### SKILL.safehands.md Content Verification
215
-
216
- | Required Section | Present |
217
- |---|---|
218
- | Skill name | ✅ `safehands-guard` |
219
- | Description | ✅ "Transaction Safety Firewall / Guardrail Skill" |
220
- | When to use | ✅ 4 use cases listed |
221
- | When not to use | ✅ Clear boundary with Pharos Skill Engine |
222
- | Capability index | ✅ 6 capabilities with reference links |
223
- | Pharos Atlantic Testnet context | ✅ Table with env, chain ID, mainnet=false |
224
- | Safety disclaimer | ✅ "not audited for mainnet production use" |
225
- | Agent behavior guidelines | ✅ 10 rules |
226
- | Link to references | ✅ `references/safehands.md` |
227
-
228
- ---
229
-
230
- ## 9. Security Status
231
-
232
- | Check | Result |
233
- |---|---|
234
- | No `.env` included in repo or package | ✅ |
235
- | No `wallet-store.json` included | ✅ |
236
- | No private keys included | ✅ |
237
- | No `*.pem` or `*.key` included | ✅ |
238
- | No logs included | ✅ |
239
- | No `node_modules` in npm package | ✅ |
240
- | Private key only through SignerProvider | ✅ Only in `src/lib/signer/index.ts` |
241
- | No direct `process.env.PRIVATE_KEY` outside signer | ✅ Verified by grep and smoke test |
242
- | Write tools disabled by default | ✅ `WRITE_TOOLS_ENABLED=false` in `.env.example` |
243
- | Unlimited approval disabled by default | ✅ `ALLOW_UNLIMITED_APPROVAL=false` in `.env.example` |
244
- | No wallet created on import/startup | ✅ Explicit `create_agent_wallet` only |
245
- | x402 signed payloads not logged | ✅ `headerRedacted: true` in response |
246
- | Managed wallet labeled testnet-grade | ✅ In SECURITY.md and README |
247
- | Mainnet support not claimed | ✅ All docs say testnet-only |
248
- | `.env.example` has no secret-looking values | ✅ All keys are empty or safe defaults |
249
- | `npm pack --dry-run` excludes all unsafe files | ✅ 194 clean files, 0 unsafe |
250
-
251
- ---
252
-
253
- ## 10. Gaps or Overclaims
254
-
255
- ### Honest Gaps
256
-
257
- 1. **Live RPC dependency.** `safehands_wallet_health` requires a live Pharos Atlantic Testnet RPC connection to read balances. When RPC is unavailable, it returns `DEGRADED` status — this is correct behavior, not a bug.
258
-
259
- 2. **DODO API dependency.** `get_token_price` requires `DODO_API_KEY` and a live DODO API. Without it, the smoke test correctly accepts `DODO_API_AUTH_REQUIRED` as a valid failure. Price data is unavailable without external API configuration.
260
-
261
- 3. **No mocked unit test suite.** All testing uses live tool handlers against real (or absent) services. A formal mocked provider test suite would improve long-term maintainability but is not a blocker for hackathon submission.
262
-
263
- 4. **Some token addresses are PROJECT_CONFIGURED.** USDT, WBTC, WETH, WPHRS, and FaroSwap/DODO router addresses are project constants without independent verification from official Pharos docs. This is honestly labeled in the source code.
264
-
265
- 5. **Demo `--demo` output includes MCP stderr.** When run as `node dist/index.js --demo`, the stderr shows the MCP write-tools-disabled warning before the process exits. This is cosmetic only — the demo completes successfully and exits with code 0.
266
-
267
- ### No Overclaims Found
268
-
269
- - The project does not claim mainnet readiness.
270
- - The project does not claim production-grade custody.
271
- - The project does not claim formal audit status.
272
- - Token addresses are labeled with their verification status.
273
-
274
- ---
275
-
276
- ## 11. Required Fixes Before Submission
277
-
278
- **None.** All validation commands pass. The one fix applied during this audit (the `setTimeout` for clean demo exit on Windows) is already committed to the source.
279
-
280
- ---
281
-
282
- ## 12. Optional Improvements After Submission
283
-
284
- 1. **Mocked provider unit tests.** Add a formal test framework (vitest/jest) with mocked RPC/DODO/GoPlus providers.
285
- 2. **KMS/Vault integration.** Replace managed wallet local storage with proper KMS for any post-hackathon custody use.
286
- 3. **Verify DODO/FaroSwap router addresses.** Cross-reference against official Pharos or DODO documentation when available.
287
- 4. **Suppress MCP stderr during `--demo`.** Redirect MCP initialization warnings to avoid cosmetic noise in demo output.
288
- 5. **Daily spend accounting.** The config value `MAX_DAILY_SPEND_USD` exists but tracking is not persisted in this MVP.
289
-
290
- ---
291
-
292
- ## 13. Final Status
293
-
294
- **Status: Ready for DoraHacks Phase 1 submission**
295
-
296
- All validation criteria are met:
297
- - ✅ Build passes
298
- - ✅ TypeScript strict typecheck passes
299
- - ✅ 37/37 smoke tests pass
300
- - ✅ 0 high-level production vulnerabilities
301
- - ✅ Demo runs deterministically without transactions
302
- - ✅ npm pack is secret-safe
303
- - ✅ MCP server starts with 27 registered tools
304
- - ✅ CLI returns valid JSON envelope
305
- - ✅ Pharos Skill Engine adapter is complete and agent-usable
306
- - ✅ All security checks pass
307
- - ✅ No overclaims found
@@ -1,147 +0,0 @@
1
- # SafeHands-Pharos — Live Docs & Testnet Verification Report
2
-
3
- > **Date:** 2026-06-12
4
- > **Version:** 1.2.0
5
-
6
- ---
7
-
8
- ## 1. Files Changed
9
-
10
- | File | Change |
11
- |------|--------|
12
- | `src/lib/constants.ts` | USDT, WBTC, WETH, WPHRS verification upgraded from `PROJECT_CONFIGURED` → `DOCS_VERIFIED` after confirming against official Pharos Token Registry |
13
- | `src/tools/tokenRegistryStatus.ts` | Handler now reads `verificationStatus` from registry entries directly |
14
- | `src/lib/testRpcLive.ts` | **NEW** — Live RPC verification with structured output |
15
- | `src/lib/testLiveSafehands.ts` | **NEW** — 7-point live CLI verification |
16
- | `src/lib/testX402Live.ts` | **NEW** — x402 behavior verification (local server) |
17
- | `src/lib/testDodoLive.ts` | **NEW** — DODO/FaroSwap live verification with clean skip |
18
- | `package.json` | Added 4 new npm scripts |
19
- | `README.md` | Added Real Testnet Verification section + updated Tests section |
20
- | `OFFICIAL_DOCS_ALIGNMENT_REPORT.md` | **NEW** — Full docs alignment table |
21
-
22
- ## 2. Official Docs Checked
23
-
24
- | Source | Fetched |
25
- |--------|---------|
26
- | https://docs.pharos.xyz/getting-started/network/atlantic-testnet | ✅ |
27
- | https://docs.pharos.xyz/getting-started/token-registry | ✅ |
28
- | https://docs.pharos.xyz/getting-started/canonical-contracts | ✅ |
29
- | https://docs.pharos.xyz/developer-guide/x402 | ✅ |
30
- | https://docs.pharos.xyz/tooling-and-infrastructure/pharos-skill-engine-guide | ✅ |
31
- | https://developers.circle.com/stablecoins/usdc-contract-addresses | ✅ |
32
- | https://docs.faroswap.xyz/en/introduction | ❌ HTTP 307 |
33
-
34
- ## 3. Docs Alignment Summary
35
-
36
- - **13 DOCS_VERIFIED** — Environment, Chain ID, RPC, Explorer, Native Token, USDC, USDT, WBTC, WETH, WPHRS, x402 behavior, Skill Engine structure, Testnet scope
37
- - **1 DOCS_DEMO_NON_OFFICIAL** — x402 demo token
38
- - **4 PROJECT_CONFIGURED** — DODO Approve, DODO Route Proxy, Position Manager, RiskRegistry
39
- - **0 CONFLICT**
40
-
41
- ## 4. Real RPC Test Result
42
-
43
- ```
44
- npm run test:rpc:live
45
- ```
46
-
47
- | Check | Result |
48
- |-------|--------|
49
- | RPC reachable | ✅ yes |
50
- | Chain ID | 688689 ✅ match |
51
- | Latest block | 24023029 |
52
- | Wallet balance | SKIPPED_NO_WALLET_ADDRESS |
53
- | **Status** | **PASS** |
54
-
55
- ## 5. Real SafeHands CLI Check Result
56
-
57
- ```
58
- npm run test:live:safehands
59
- ```
60
-
61
- | # | Check | Result |
62
- |---|-------|--------|
63
- | 1 | wallet_health_no_wallet | ✅ PASS |
64
- | 2 | token_registry_canonical_usdc (DOCS_VERIFIED) | ✅ PASS |
65
- | 3 | token_registry_x402_demo (DOCS_DEMO_NON_OFFICIAL) | ✅ PASS |
66
- | 4 | token_registry_usdt_docs_verified | ✅ PASS |
67
- | 5 | preflight_block_unlimited_approval | ✅ PASS |
68
- | 6 | preflight_block_mainnet | ✅ PASS |
69
- | 7 | preflight_allow_testnet | ✅ PASS |
70
- | **Status** | **7/7 PASS** |
71
-
72
- ## 6. Real x402 Behavior Result
73
-
74
- ```
75
- npm run test:x402:live
76
- ```
77
-
78
- **Label: LOCAL_X402_SERVER_DOCS_BEHAVIOR_TEST**
79
-
80
- | # | Check | Result |
81
- |---|-------|--------|
82
- | 1 | /supported without private key | ✅ 200 OK |
83
- | 2 | /health without private key | ✅ 200 OK |
84
- | 3 | Paid endpoint without config → structured 503 | ✅ |
85
- | 4 | No crash on missing config | ✅ |
86
- | 5 | x402 token matches docs (USDC on eip155:688689) | ✅ |
87
- | **Status** | **5/5 PASS** |
88
-
89
- ## 7. DODO/FaroSwap Real Verification Result
90
-
91
- ```
92
- npm run test:dodo:live
93
- ```
94
-
95
- | # | Check | Result |
96
- |---|-------|--------|
97
- | 1 | DODO API route check | ⏭️ SKIPPED_MISSING_DODO_API_KEY |
98
- | 2 | DODO Approve address verification | ✅ PROJECT_CONFIGURED |
99
- | 3 | DODO Route Proxy verification | ✅ PROJECT_CONFIGURED |
100
- | **Status** | **2/3 PASS, 1 SKIPPED** |
101
-
102
- ## 8. Address Metadata Changes
103
-
104
- | Token | Before | After | Source |
105
- |-------|--------|-------|--------|
106
- | USDC | DOCS_VERIFIED | DOCS_VERIFIED | Token Registry + Circle |
107
- | TUSDC | DOCS_DEMO_NON_OFFICIAL | DOCS_DEMO_NON_OFFICIAL | x402 docs |
108
- | USDT | (no verificationStatus) | **DOCS_VERIFIED** | Token Registry |
109
- | WBTC | (no verificationStatus) | **DOCS_VERIFIED** | Token Registry |
110
- | WETH | (no verificationStatus) | **DOCS_VERIFIED** | Token Registry |
111
- | WPHRS | (no verificationStatus) | **DOCS_VERIFIED** | Token Registry |
112
- | DODO addresses | PROJECT_CONFIGURED | PROJECT_CONFIGURED | FaroSwap docs unavailable |
113
- | RiskRegistry | PROJECT_CONFIGURED | PROJECT_CONFIGURED | Not in canonical contracts |
114
-
115
- ## 9. Commands Run and Results
116
-
117
- | Command | Exit Code |
118
- |---------|-----------|
119
- | `npm run build` | 0 ✅ |
120
- | `npx tsc -p tsconfig.all.json --pretty false` | 0 ✅ |
121
- | `npm audit --omit=dev --audit-level=high` | 0 ✅ (0 vulnerabilities) |
122
- | `npm pack --dry-run` | 0 ✅ (210 files, 128.4 kB) |
123
- | `npm run test:all` | 0 ✅ (37/37 passed) |
124
- | `npm run demo` | 0 ✅ |
125
- | `npm run test:rpc:live` | 0 ✅ (PASS) |
126
- | `npm run test:live:safehands` | 0 ✅ (7/7) |
127
- | `npm run test:x402:live` | 0 ✅ (5/5) |
128
- | `npm run test:dodo:live` | 0 ✅ (2/3, 1 skipped) |
129
-
130
- ## 10. Remaining Docs-Unverified Values
131
-
132
- | Value | Status | Reason |
133
- |-------|--------|--------|
134
- | DODO Approve Address `0x4Cf3…` | PROJECT_CONFIGURED | FaroSwap docs HTTP 307 |
135
- | DODO Route Proxy `0x8198…` | PROJECT_CONFIGURED | FaroSwap docs HTTP 307 |
136
- | Position Manager `0x1c43…` | PROJECT_CONFIGURED | FaroSwap docs HTTP 307 |
137
- | RiskRegistry `0x71fc…` | PROJECT_CONFIGURED | Custom project deployment |
138
-
139
- ## 11. Real Transactions Broadcast
140
-
141
- **None.** Zero transactions were signed or broadcast during this verification pass. All tests are read-only RPC calls, deterministic preflight policy checks, or local server behavior tests.
142
-
143
- ## 12. Final Status
144
-
145
- **Status: Ready for DoraHacks Phase 1 submission with real docs/live verification**
146
-
147
- All 13 docs-verifiable values match official Pharos documentation. Live RPC confirms chain ID 688689 and block production. 37 smoke tests + 7 CLI checks + 5 x402 checks pass. DODO skips cleanly. Zero vulnerabilities. No overclaimed addresses.
@@ -1,85 +0,0 @@
1
- # SafeHands-Pharos — Official Pharos Skill Engine Alignment Report
2
-
3
- > **Date:** 2026-06-12
4
- > **Version:** 1.2.0
5
-
6
- ---
7
-
8
- ## 1. Files Changed
9
- | File | Change |
10
- |------|--------|
11
- | `src/lib/constants.ts` | Upgraded `0xE0BE08c7...` to primary `USDC_ADDRESS`, relabeled `0xcfC8330f...` as `CIRCLE_USDC_ADDRESS`. |
12
- | `src/tools/tokenRegistryStatus.ts` | Rewrote classification to output `SKILL_ENGINE_CANONICAL_TOKEN` or `ALTERNATE_SOURCE_TOKEN` based on new registry metadata. |
13
- | `skill/SKILL.md` | **NEW** — Created official SKILL.md file adhering to Pharos Skill Engine formatting standards with YAML frontmatter. |
14
- | `skill/references/safehands.md` | **NEW** — Copied over the CLI reference guide into the required skill package structure. |
15
- | `skill/assets/safehands/*` | **NEW** — Policy defaults and example actions migrated. Example actions now strictly use `0xE0BE08c7...`. |
16
- | `src/lib/testTools.ts` | Added 6 new smoke tests covering the `skill/` package structure and exact token metadata values. |
17
- | `src/lib/testLiveSafehands.ts` | Updated live CLI checks to verify new USDC classification. |
18
- | `src/index.ts` | Fixed the `--demo` exit path bug to ensure test pipelines exit cleanly without starting the MCP server inadvertently. |
19
- | `package.json` | Appended the `skill` directory and new alignment reports to the npm `files` array for proper packaging. |
20
- | `README.md` | Added the "Official Pharos Skill Engine Alignment" section and updated token addresses in the context table. |
21
- | `OFFICIAL_DOCS_ALIGNMENT_REPORT.md` | Updated docs alignment tables and summaries to reflect the Skill Engine metadata. |
22
-
23
- ## 2. Official Pharos Skill Engine Zip Findings
24
- Inspection of `pharos-skill-engine-0.1.0.zip` revealed:
25
- - **Structure:** `SKILL.md`, `references/`, and `assets/`.
26
- - **Token Metadata:** The file `assets/tokens.json` officially defines the Atlantic Testnet USDC address as **`0xE0BE08c77f415F577A1B3A9aD7a1Df1479564ec8`**.
27
- - **Role:** The official skill handles execution (`cast`/`forge`), confirming SafeHands' positioning as a complementary preflight guardrail rather than an execution wrapper.
28
-
29
- ## 3. Token Metadata Changes
30
- - **Primary USDC (`0xE0BE08c7...`)**: The official Pharos Skill Engine token (previously treated as a docs demo token) has been promoted to the canonical testnet USDC default.
31
- - **Status:** `SKILL_ENGINE_CANONICAL_TOKEN`
32
- - **Verification:** `DOCS_VERIFIED_FROM_PHAROS_SKILL_ENGINE`
33
- - **Alternate USDC (`0xcfC8330f...`)**: The USDC address sourced from Circle's official documentation is preserved but deprioritized to avoid conflicts.
34
- - **Status:** `ALTERNATE_SOURCE_TOKEN`
35
- - **Verification:** `CIRCLE_REFERENCED_USDC`
36
-
37
- Both tokens are handled gracefully by `token_registry_status`, ensuring the agent receives factual provenance.
38
-
39
- ## 4. Skill Package Structure Created
40
- The `skill/` directory was generated successfully, mirroring the PiggyBank template layout:
41
- ```text
42
- skill/
43
- ├── SKILL.md (with YAML frontmatter, Capability Index, Pre-checks)
44
- ├── references/
45
- │ └── safehands.md
46
- └── assets/
47
- └── safehands/
48
- ├── policy-defaults.json
49
- └── example-actions.json
50
- ```
51
- The package allows an AI agent to dynamically invoke `safehands_preflight_check` using official Pharos patterns.
52
-
53
- ## 5. Tests Added/Updated
54
- - **`skill_package_skill_md_exists`**: Confirms presence of `SKILL.md`.
55
- - **`skill_package_yaml_frontmatter`**: Ensures exact match for `name: safehands-pharos-guard` in frontmatter.
56
- - **`skill_package_references_exist`**: Verifies presence of the `references/safehands.md` guide.
57
- - **`skill_package_assets_exist`**: Verifies presence of the JSON assets.
58
- - **`skill_package_example_uses_skill_engine_usdc`**: Blocks regressions to the `0xcfC8...` address within example configs.
59
- - **`token_registry_circle_usdc_alternate`**: Ensures `0xcfC8...` retains its explicit alternate status.
60
- - **`demo_runs_or_fails_gracefully`**: Fixed to properly handle the exit code when the demo runs successfully.
61
-
62
- ## 6. Commands Run and Results
63
- | Command | Result |
64
- |---------|--------|
65
- | `npm ci` | 0 ✅ |
66
- | `npm run build` | 0 ✅ |
67
- | `npx tsc -p tsconfig.all.json --pretty false` | 0 ✅ |
68
- | `npm run test:all` | 0 ✅ (43/43 smoke tests passed) |
69
- | `npm audit --omit=dev --audit-level=high` | 0 ✅ (0 vulnerabilities) |
70
- | `npm run demo` | 0 ✅ (Clean exit, output identical to previous demo) |
71
-
72
- ## 7. npm pack Safety Result
73
- ```bash
74
- npm pack --dry-run
75
- ```
76
- - Includes the new `skill/` directory and `OFFICIAL_DOCS_ALIGNMENT_REPORT.md`.
77
- - **Secret scan**: Passed (0 exposed variables found).
78
- - **Total files:** 215 files (135.9 kB).
79
-
80
- ## 8. Remaining Risks/TODOs
81
- - **DODO / FaroSwap Router Addresses:** Currently `PROJECT_CONFIGURED`. This remains unverified due to the FaroSwap documentation returning an HTTP 307 redirect. This cannot be fixed without live docs.
82
- - **RiskRegistry Contract:** A project-deployed contract (`PROJECT_CONFIGURED`) used to simulate risk scores. Expected hackathon behavior.
83
-
84
- ## 9. Final Status
85
- **Status: Ready for DoraHacks Phase 1 submission with official Pharos Skill Engine alignment**