@exagent/agent 0.3.8 → 0.3.10

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.
@@ -2871,6 +2871,7 @@ var HyperliquidClient = class {
2871
2871
  fee: fill.fee,
2872
2872
  time: fill.time,
2873
2873
  hash: fill.hash,
2874
+ tid: fill.tid,
2874
2875
  isMaker: fill.startPosition !== fill.px,
2875
2876
  builderFee: fill.builderFee,
2876
2877
  liquidation: fill.liquidation
@@ -4094,6 +4095,11 @@ var PolymarketClient = class {
4094
4095
  parseRawFill(raw) {
4095
4096
  const tokenId = raw.asset_id || void 0;
4096
4097
  const marketConditionId = raw.market || raw.asset_id || "";
4098
+ const timestampRaw = raw.match_time ?? raw.timestamp ?? raw.created_at ?? raw.last_update;
4099
+ const timestampNumber = typeof timestampRaw === "number" ? timestampRaw : typeof timestampRaw === "string" && /^\d+$/.test(timestampRaw) ? Number(timestampRaw) : null;
4100
+ const timestamp = timestampNumber ? timestampNumber < 1e10 ? timestampNumber * 1e3 : timestampNumber : timestampRaw ? new Date(timestampRaw).getTime() : Date.now();
4101
+ const rawTxHash = raw.transaction_hash || raw.transactionHash || void 0;
4102
+ const transactionHash = typeof rawTxHash === "string" && /^0x[a-fA-F0-9]{64}$/.test(rawTxHash) ? rawTxHash : void 0;
4097
4103
  return {
4098
4104
  orderId: raw.orderId || raw.order_id || "",
4099
4105
  tradeId: raw.id || raw.tradeId || "",
@@ -4102,10 +4108,13 @@ var PolymarketClient = class {
4102
4108
  side: raw.side === "BUY" || raw.side === "buy" ? "BUY" : "SELL",
4103
4109
  price: String(raw.price || "0"),
4104
4110
  size: String(raw.size || "0"),
4105
- fee: String(raw.fee || "0"),
4106
- timestamp: raw.timestamp || raw.created_at ? new Date(raw.created_at).getTime() : Date.now(),
4111
+ fee: String(raw.fee || raw.fee_usdc || "0"),
4112
+ timestamp,
4107
4113
  isMaker: raw.maker_order || raw.is_maker || false,
4108
- tokenId
4114
+ tokenId,
4115
+ status: raw.status || void 0,
4116
+ transactionHash,
4117
+ traderSide: raw.trader_side || raw.traderSide || void 0
4109
4118
  };
4110
4119
  }
4111
4120
  };
@@ -5150,7 +5159,7 @@ import { privateKeyToAccount as privateKeyToAccount3 } from "viem/accounts";
5150
5159
  import { arbitrum as arbitrum2 } from "viem/chains";
5151
5160
  import { createRequire } from "module";
5152
5161
  var _require = createRequire(import.meta.url);
5153
- var SDK_VERSION = "0.3.7";
5162
+ var SDK_VERSION = "0.3.10";
5154
5163
  try {
5155
5164
  SDK_VERSION = _require("../package.json").version;
5156
5165
  } catch {
@@ -6021,7 +6030,15 @@ var AgentRuntime = class _AgentRuntime {
6021
6030
  price: result.effectivePrice,
6022
6031
  fee: Number(result.gasCost) / 1e18,
6023
6032
  venueFillId: result.txHash,
6024
- venueTimestamp: (/* @__PURE__ */ new Date()).toISOString()
6033
+ venueTimestamp: (/* @__PURE__ */ new Date()).toISOString(),
6034
+ txHash: result.txHash,
6035
+ evidence: {
6036
+ source: "evm_transaction",
6037
+ tokenIn: result.tokenIn,
6038
+ tokenOut: result.tokenOut,
6039
+ amountIn: result.amountIn.toString(),
6040
+ amountOut: result.amountOut.toString()
6041
+ }
6025
6042
  };
6026
6043
  const baseToken = parts[0] ?? sig.symbol;
6027
6044
  let realizedPnL = 0;
@@ -6082,7 +6099,8 @@ var AgentRuntime = class _AgentRuntime {
6082
6099
  price: sig.price || 1,
6083
6100
  fee: Number(result.fee) / 10 ** decimals,
6084
6101
  venueFillId: result.depositTxHash,
6085
- venueTimestamp: (/* @__PURE__ */ new Date()).toISOString()
6102
+ venueTimestamp: (/* @__PURE__ */ new Date()).toISOString(),
6103
+ txHash: result.depositTxHash
6086
6104
  };
6087
6105
  this.signal.reportBridgeFill(tradeSignal);
6088
6106
  getLogger().info("bridge", "Bridge completed", { from: fromChain, to: toChain, bridge: "across" });
@@ -6187,6 +6205,7 @@ var AgentRuntime = class _AgentRuntime {
6187
6205
  }
6188
6206
  // ── FILL HANDLING ──────────────────────────────────────────
6189
6207
  handleHyperliquidFill(fill) {
6208
+ const fillId = fill.tid ? `hyperliquid:${fill.tid}` : fill.hash;
6190
6209
  const tradeSignal = {
6191
6210
  venue: "hyperliquid_perp",
6192
6211
  symbol: fill.coin,
@@ -6194,9 +6213,16 @@ var AgentRuntime = class _AgentRuntime {
6194
6213
  size: parseFloat(fill.sz),
6195
6214
  price: parseFloat(fill.px),
6196
6215
  fee: parseFloat(fill.fee),
6197
- venueFillId: fill.hash,
6216
+ venueFillId: fillId,
6198
6217
  venueTimestamp: new Date(fill.time).toISOString(),
6199
- orderType: fill.isMaker ? "limit" : "market"
6218
+ orderType: fill.isMaker ? "limit" : "market",
6219
+ txHash: fill.hash,
6220
+ evidence: {
6221
+ source: "hyperliquid_user_fills",
6222
+ tid: fill.tid ?? null,
6223
+ hash: fill.hash,
6224
+ oid: fill.oid
6225
+ }
6200
6226
  };
6201
6227
  const action = fill.side === "B" ? "buy" : "sell";
6202
6228
  const fee = parseFloat(fill.fee);
@@ -6209,7 +6235,7 @@ var AgentRuntime = class _AgentRuntime {
6209
6235
  fee,
6210
6236
  "hyperliquid_perp",
6211
6237
  void 0,
6212
- fill.hash
6238
+ fillId
6213
6239
  );
6214
6240
  } else {
6215
6241
  realizedPnL = this.positions.recordSell(
@@ -6219,7 +6245,7 @@ var AgentRuntime = class _AgentRuntime {
6219
6245
  fee,
6220
6246
  "hyperliquid_perp",
6221
6247
  void 0,
6222
- fill.hash
6248
+ fillId
6223
6249
  );
6224
6250
  }
6225
6251
  this.risk.recordTrade(realizedPnL, fee);
@@ -6245,7 +6271,16 @@ var AgentRuntime = class _AgentRuntime {
6245
6271
  price: parseFloat(fill.price),
6246
6272
  fee: parseFloat(fill.fee),
6247
6273
  venueFillId: fill.tradeId,
6248
- venueTimestamp: new Date(fill.timestamp).toISOString()
6274
+ venueTimestamp: new Date(fill.timestamp).toISOString(),
6275
+ txHash: fill.transactionHash,
6276
+ evidence: {
6277
+ source: "polymarket_clob",
6278
+ status: fill.status,
6279
+ transactionHash: fill.transactionHash,
6280
+ orderId: fill.orderId,
6281
+ traderSide: fill.traderSide,
6282
+ tokenId: fill.tokenId
6283
+ }
6249
6284
  };
6250
6285
  const fillFee = parseFloat(fill.fee);
6251
6286
  let realizedPnL = 0;
package/dist/cli.js CHANGED
@@ -9,7 +9,7 @@ import {
9
9
  updateSecureStore,
10
10
  writeConfigFile,
11
11
  writeSampleConfig
12
- } from "./chunk-GYYW4EKM.js";
12
+ } from "./chunk-X6TXKSWB.js";
13
13
 
14
14
  // src/cli.ts
15
15
  import { Command } from "commander";
@@ -359,7 +359,7 @@ async function ensureLocalSetup(configPath) {
359
359
  // src/cli.ts
360
360
  import * as clack2 from "@clack/prompts";
361
361
  var program = new Command();
362
- program.name("exagent").description("Exagent \u2014 LLM trading agent runtime").version("0.3.8");
362
+ program.name("exagent").description("Exagent \u2014 LLM trading agent runtime").version("0.3.10");
363
363
  program.command("init").description("Create a sample agent configuration file").option("--agent-id <id>", "Agent ID (from dashboard)", "my-agent").option("--api-url <url>", "API server URL", "http://localhost:3002").option("--config <path>", "Config file path", "agent-config.json").action((opts) => {
364
364
  printBanner();
365
365
  writeSampleConfig(opts.agentId, opts.apiUrl, opts.config);
package/dist/index.d.ts CHANGED
@@ -1,7 +1,16 @@
1
- import { LLMProvider, StrategyProvenance, StrategyPermissions, RelayCommand, AgentStatusPayload, MessageType, MessageLevel, TradeSignal, StrategyStore, PositionSummary, TrackedPosition, TradeRecord, LLMAdapter, LLMConfig, LLMMessage, LLMResponse, LLMMetadata, StrategyFunction, StrategyTemplate, RiskParams, MarketData, OHLCV, PaperTrade, PaperMetrics } from '@exagent/sdk';
1
+ import { LLMProvider, RelayCommand, AgentStatusPayload, MessageType, MessageLevel, TradeSignal, StrategyStore, PositionSummary, TrackedPosition, TradeRecord, LLMAdapter, LLMConfig, LLMMessage, LLMResponse, LLMMetadata, StrategyFunction, StrategyTemplate, RiskParams, MarketData, OHLCV, PaperTrade, PaperMetrics } from '@exagent/sdk';
2
2
  import { WalletClient, PublicClient, Transport, Chain as Chain$1, Account } from 'viem';
3
3
  import { Chain } from 'viem/chains';
4
4
 
5
+ type StrategyProvenance = 'template' | 'user_created' | 'imported' | 'marketplace' | 'admin_approved' | 'legacy_code';
6
+ interface StrategyPermissions {
7
+ allowedVenues?: string[];
8
+ allowedChains?: string[];
9
+ maxTradeValueUSD?: number;
10
+ maxLeverage?: number;
11
+ allowedOrderTypes?: Array<'market' | 'limit' | 'yes' | 'no'>;
12
+ maxDailyLossBps?: number;
13
+ }
5
14
  interface RuntimeConfig {
6
15
  agentId: string;
7
16
  apiUrl: string;
@@ -615,6 +624,7 @@ interface PerpFill {
615
624
  fee: string;
616
625
  time: number;
617
626
  hash: string;
627
+ tid?: number;
618
628
  isMaker: boolean;
619
629
  builderFee?: string;
620
630
  liquidation?: boolean;
@@ -1031,6 +1041,9 @@ interface PredictionFill {
1031
1041
  marketQuestion?: string;
1032
1042
  isMaker: boolean;
1033
1043
  tokenId?: string;
1044
+ status?: string;
1045
+ transactionHash?: `0x${string}`;
1046
+ traderSide?: string;
1034
1047
  }
1035
1048
  interface PredictionOrderResult {
1036
1049
  success: boolean;
package/dist/index.js CHANGED
@@ -43,7 +43,7 @@ import {
43
43
  loadConfig,
44
44
  loadStrategy,
45
45
  writeSampleConfig
46
- } from "./chunk-GYYW4EKM.js";
46
+ } from "./chunk-X6TXKSWB.js";
47
47
  export {
48
48
  AcrossAdapter,
49
49
  AerodromeAdapter,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exagent/agent",
3
- "version": "0.3.8",
3
+ "version": "0.3.10",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -17,13 +17,13 @@
17
17
  }
18
18
  },
19
19
  "scripts": {
20
- "build": "tsup src/index.ts src/cli.ts --format esm --dts",
20
+ "build": "rm -rf dist && tsup src/index.ts src/cli.ts --format esm --dts",
21
21
  "dev": "tsup src/index.ts src/cli.ts --format esm --dts --watch",
22
22
  "test": "tsx --test test/**/*.test.ts"
23
23
  },
24
24
  "dependencies": {
25
25
  "@clack/prompts": "^1.1.0",
26
- "@exagent/sdk": "0.2.2",
26
+ "@exagent/sdk": "0.2.3",
27
27
  "@polymarket/clob-client": "^5.8.1",
28
28
  "boxen": "^8.0.1",
29
29
  "commander": "^12.1.0",