@dreamcash-org/mcp 0.2.0 → 0.3.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.
@@ -707,7 +707,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
707
707
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
708
708
  THE SOFTWARE.
709
709
 
710
- ## @noble/hashes 1.8.0 (MIT)
710
+ ## @noble/hashes 2.3.0 (MIT)
711
711
 
712
712
  The MIT License (MIT)
713
713
 
@@ -731,7 +731,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
731
731
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
732
732
  THE SOFTWARE.
733
733
 
734
- ## @noble/hashes 2.3.0 (MIT)
734
+ ## @noble/hashes 1.8.0 (MIT)
735
735
 
736
736
  The MIT License (MIT)
737
737
 
@@ -21370,6 +21370,7 @@ var CALIBUR_EIP712_DOMAIN = {
21370
21370
  salt: `0x${CALIBUR_ADDRESS.slice(2).padStart(64, "0")}`
21371
21371
  };
21372
21372
  // ../constants/src/hyperliquid/aiAgent.ts
21373
+ var AI_REPLY_STYLE = "How to reply: lead with the answer in a line or two, in the user's own words, and add detail only when asked. No tables or extra sections for a simple question. Never show tool or field names, and skip exchange mechanics the user didn't ask about. Say once in a chat, not in each reply, that what you suggest is your own analysis, not advice from Dreamcash. A liquidation price over 90% away means the position practically can't be liquidated: say that, not the number.";
21373
21374
  var AI_CLIENT_NAME_MAX_LENGTH = 60;
21374
21375
  var TRADE_REQUEST_TTL_MS = 15 * 60 * 1000;
21375
21376
  var AI_AGENT_SIGNATURE_HEADER = "x-dreamcash-agent-signature";
@@ -21456,7 +21457,7 @@ import { createHash } from "node:crypto";
21456
21457
  // package.json
21457
21458
  var package_default = {
21458
21459
  name: "@dreamcash-org/mcp",
21459
- version: "0.2.0",
21460
+ version: "0.3.0",
21460
21461
  description: "Connect your own AI agent to your Dreamcash account: it reads your account and trades, each trade confirmed by you or on its own within your limits.",
21461
21462
  license: "MIT",
21462
21463
  keywords: [
@@ -48596,7 +48597,8 @@ var SERVER_FILLED = new Set([
48596
48597
  "orderType",
48597
48598
  "reduceOnly",
48598
48599
  "slippagePct",
48599
- "percent"
48600
+ "percent",
48601
+ "marginMode"
48600
48602
  ]);
48601
48603
  var checkAgentRequest = async ({
48602
48604
  claimed,
@@ -48705,11 +48707,13 @@ var executeTradeRequest = async ({
48705
48707
  // src/dreamcashServer.ts
48706
48708
  var INSTRUCTIONS = `Dreamcash is a Hyperliquid trading app. This server connects you to the user's Dreamcash account. Until you're connected, connect_dreamcash is your only tool: ask the user for the 6-character code their Dreamcash app shows (Settings › Connected AI) and call it with that code. You then get tools to read their account (balances, positions, orders, history, PnL, XP, vaults) and Hyperliquid markets, and to ask for trades, which the user approves in their Dreamcash app, or, if they let you, to trade on your own with your own key, kept on this machine (Dreamcash never sees it). Once connected, call how_to_use_dreamcash first: it explains every tool, what you may do and how to behave.
48707
48709
 
48708
- Anything that fails answers {"error": {code, what_happened, what_to_do, tell_the_user, can_retry}}: do what_to_do, and pass tell_the_user on to the user. Amounts are USD unless stated. What you suggest is your own analysis, not advice from Dreamcash.`;
48710
+ Anything that fails answers {"error": {code, what_happened, what_to_do, tell_the_user, can_retry}}: do what_to_do, and pass tell_the_user on to the user. Amounts are USD unless stated.
48711
+
48712
+ ${AI_REPLY_STYLE}`;
48709
48713
  var CONNECT_TOOL = {
48710
48714
  name: "connect_dreamcash",
48711
48715
  title: "Connect to Dreamcash",
48712
- description: "Connects you to the user's Dreamcash account with the 6-character code their Dreamcash app shows under Settings › Connected AI. Without a code it answers whether you're connected, and if not, what to ask the user. again: true pairs a new key, e.g. after the user disconnected you; the key before it keeps working until the new one pairs.",
48716
+ description: "Connects you to the user's Dreamcash account with the 6-character code their Dreamcash app shows under Settings › Connected AI. Without a code it answers whether you're connected, and if not, what to ask the user. again: true pairs a new key, e.g. after the user disconnected you, which revoked your key at once (on Hyperliquid and at Dreamcash). If a new pairing fails, the package keeps the key it had, which works only while that connection is still on.",
48713
48717
  inputSchema: {
48714
48718
  type: "object",
48715
48719
  properties: {
@@ -48815,6 +48819,43 @@ var guidanceFor = (error2) => {
48815
48819
  }
48816
48820
  return unreachable(error2);
48817
48821
  };
48822
+ var withExecution = (content, executed) => content.map((block) => {
48823
+ if (block.type !== "text")
48824
+ return block;
48825
+ try {
48826
+ const answer = JSON.parse(block.text);
48827
+ if (answer.execute_with_agent_key !== true)
48828
+ return block;
48829
+ const { execute_with_agent_key: _carriedOut, ...asked } = answer;
48830
+ return {
48831
+ ...block,
48832
+ text: JSON.stringify({
48833
+ ...asked,
48834
+ status: "status" in executed && typeof executed.status === "string" ? executed.status : asked.status,
48835
+ executed_with_your_key: executed
48836
+ })
48837
+ };
48838
+ } catch {
48839
+ return block;
48840
+ }
48841
+ });
48842
+ var fillTotalsOf = (content) => {
48843
+ const text2 = content.find((block) => block.type === "text");
48844
+ if (!text2 || text2.type !== "text")
48845
+ return;
48846
+ try {
48847
+ const { result } = JSON.parse(text2.text);
48848
+ if (typeof result?.fees_usd !== "number")
48849
+ return;
48850
+ return {
48851
+ realized_pnl_usd: result.realized_pnl_usd,
48852
+ fees_usd: result.fees_usd,
48853
+ dreamcash_part_of_fees_usd: result.dreamcash_part_of_fees_usd
48854
+ };
48855
+ } catch {
48856
+ return;
48857
+ }
48858
+ };
48818
48859
  var tradeRequestToExecute = (tool, args, result) => {
48819
48860
  if (result.isError)
48820
48861
  return;
@@ -48999,17 +49040,16 @@ var createDreamcashServer = ({
48999
49040
  const toExecute = tradeRequestToExecute(name, args, result);
49000
49041
  if (!toExecute)
49001
49042
  return result;
49043
+ const executed = await executeWithKey(toExecute.id, toExecute.asked, account);
49044
+ const totals = "status" in executed && executed.status === "executed" ? await client.callTool({
49045
+ name: "get_trade_request",
49046
+ arguments: { request_id: toExecute.id }
49047
+ }).then((readBack) => fillTotalsOf(readBack.content)).catch(() => {
49048
+ return;
49049
+ }) : undefined;
49002
49050
  return {
49003
49051
  ...result,
49004
- content: [
49005
- ...result.content,
49006
- {
49007
- type: "text",
49008
- text: JSON.stringify({
49009
- executed_with_your_key: await executeWithKey(toExecute.id, toExecute.asked, account)
49010
- })
49011
- }
49012
- ]
49052
+ content: withExecution(result.content, { ...executed, ...totals })
49013
49053
  };
49014
49054
  } catch (error2) {
49015
49055
  if (isUnauthorized(error2))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dreamcash-org/mcp",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Connect your own AI agent to your Dreamcash account: it reads your account and trades, each trade confirmed by you or on its own within your limits.",
5
5
  "license": "MIT",
6
6
  "keywords": [