@quantish/agent 0.1.7 → 0.1.9

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 (2) hide show
  1. package/dist/index.js +73 -40
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -27,7 +27,7 @@ var schema = {
27
27
  },
28
28
  model: {
29
29
  type: "string",
30
- default: "claude-sonnet-4-5-20250929"
30
+ default: "claude-sonnet-4-20250514"
31
31
  }
32
32
  };
33
33
  var ConfigManager = class {
@@ -111,7 +111,7 @@ var ConfigManager = class {
111
111
  * Get the model to use
112
112
  */
113
113
  getModel() {
114
- return this.conf.get("model") ?? "claude-sonnet-4-5-20250929";
114
+ return this.conf.get("model") ?? "claude-sonnet-4-20250514";
115
115
  }
116
116
  /**
117
117
  * Set the model to use
@@ -2287,7 +2287,7 @@ function parseCompactedSummary(response) {
2287
2287
  }
2288
2288
  return response.trim() || null;
2289
2289
  }
2290
- async function createCompactedSummary(anthropic, history, model = "claude-sonnet-4-5-20250929", customPrompt) {
2290
+ async function createCompactedSummary(anthropic, history, model = "claude-sonnet-4-20250514", customPrompt) {
2291
2291
  const prompt2 = customPrompt || COMPACTION_PROMPT;
2292
2292
  const compactionMessages = [
2293
2293
  ...history,
@@ -2331,7 +2331,7 @@ async function compactConversation(anthropic, history, model, systemPrompt, tool
2331
2331
  const contentLength = JSON.stringify(history).length;
2332
2332
  originalTokens = Math.ceil(contentLength / 4);
2333
2333
  }
2334
- const summaryModel = "claude-sonnet-4-5-20250929";
2334
+ const summaryModel = "claude-sonnet-4-20250514";
2335
2335
  const summary = await createCompactedSummary(anthropic, history, summaryModel);
2336
2336
  const newHistory = historyFromSummary(summary);
2337
2337
  let newTokens = 0;
@@ -2357,25 +2357,25 @@ async function compactConversation(anthropic, history, model, systemPrompt, tool
2357
2357
 
2358
2358
  // src/agent/pricing.ts
2359
2359
  var MODELS = {
2360
- "claude-opus-4-5-20250929": {
2361
- id: "claude-opus-4-5-20250929",
2362
- name: "opus-4.5",
2363
- displayName: "Claude Opus 4.5",
2360
+ "claude-opus-4-20250514": {
2361
+ id: "claude-opus-4-20250514",
2362
+ name: "opus-4",
2363
+ displayName: "Claude Opus 4",
2364
2364
  pricing: {
2365
- inputPerMTok: 5,
2366
- outputPerMTok: 25,
2367
- cacheWritePerMTok: 6.25,
2365
+ inputPerMTok: 15,
2366
+ outputPerMTok: 75,
2367
+ cacheWritePerMTok: 18.75,
2368
2368
  // 1.25x input
2369
- cacheReadPerMTok: 0.5
2369
+ cacheReadPerMTok: 1.5
2370
2370
  // 0.1x input
2371
2371
  },
2372
2372
  contextWindow: 2e5,
2373
2373
  description: "Most capable model. Best for complex reasoning and creative tasks."
2374
2374
  },
2375
- "claude-sonnet-4-5-20250929": {
2376
- id: "claude-sonnet-4-5-20250929",
2377
- name: "sonnet-4.5",
2378
- displayName: "Claude Sonnet 4.5",
2375
+ "claude-sonnet-4-20250514": {
2376
+ id: "claude-sonnet-4-20250514",
2377
+ name: "sonnet-4",
2378
+ displayName: "Claude Sonnet 4",
2379
2379
  pricing: {
2380
2380
  inputPerMTok: 3,
2381
2381
  outputPerMTok: 15,
@@ -2387,30 +2387,30 @@ var MODELS = {
2387
2387
  contextWindow: 2e5,
2388
2388
  description: "Balanced performance and cost. Great for most coding and trading tasks."
2389
2389
  },
2390
- "claude-haiku-4-5-20250929": {
2391
- id: "claude-haiku-4-5-20250929",
2392
- name: "haiku-4.5",
2393
- displayName: "Claude Haiku 4.5",
2390
+ "claude-3-5-haiku-20241022": {
2391
+ id: "claude-3-5-haiku-20241022",
2392
+ name: "haiku-3.5",
2393
+ displayName: "Claude Haiku 3.5",
2394
2394
  pricing: {
2395
- inputPerMTok: 1,
2396
- outputPerMTok: 5,
2397
- cacheWritePerMTok: 1.25,
2395
+ inputPerMTok: 0.8,
2396
+ outputPerMTok: 4,
2397
+ cacheWritePerMTok: 1,
2398
2398
  // 1.25x input
2399
- cacheReadPerMTok: 0.1
2399
+ cacheReadPerMTok: 0.08
2400
2400
  // 0.1x input
2401
2401
  },
2402
2402
  contextWindow: 2e5,
2403
2403
  description: "Fastest and most economical. Good for simple tasks and high volume."
2404
2404
  }
2405
2405
  };
2406
- var DEFAULT_MODEL = "claude-sonnet-4-5-20250929";
2406
+ var DEFAULT_MODEL = "claude-sonnet-4-20250514";
2407
2407
  var MODEL_ALIASES = {
2408
- "opus": "claude-opus-4-5-20250929",
2409
- "opus-4.5": "claude-opus-4-5-20250929",
2410
- "sonnet": "claude-sonnet-4-5-20250929",
2411
- "sonnet-4.5": "claude-sonnet-4-5-20250929",
2412
- "haiku": "claude-haiku-4-5-20250929",
2413
- "haiku-4.5": "claude-haiku-4-5-20250929"
2408
+ "opus": "claude-opus-4-20250514",
2409
+ "opus-4": "claude-opus-4-20250514",
2410
+ "sonnet": "claude-sonnet-4-20250514",
2411
+ "sonnet-4": "claude-sonnet-4-20250514",
2412
+ "haiku": "claude-3-5-haiku-20241022",
2413
+ "haiku-3.5": "claude-3-5-haiku-20241022"
2414
2414
  };
2415
2415
  function resolveModelId(nameOrAlias) {
2416
2416
  const lower = nameOrAlias.toLowerCase();
@@ -2751,7 +2751,28 @@ const data = await response.json();
2751
2751
  const result = JSON.parse(data.result.content[0].text);
2752
2752
  \`\`\`
2753
2753
 
2754
+ ### \u26A0\uFE0F CRITICAL: Tool-to-Server Mapping (MEMORIZE THIS)
2755
+
2756
+ | Tool Name | Server | Auth Required | Helper Function |
2757
+ |-----------|--------|---------------|-----------------|
2758
+ | \`get_balances\` | TRADING | Yes (QUANTISH_API_KEY) | callTradingTool() |
2759
+ | \`get_positions\` | TRADING | Yes | callTradingTool() |
2760
+ | \`place_order\` | TRADING | Yes | callTradingTool() |
2761
+ | \`cancel_order\` | TRADING | Yes | callTradingTool() |
2762
+ | \`get_orders\` | TRADING | Yes | callTradingTool() |
2763
+ | \`get_orderbook\` | TRADING | Yes | callTradingTool() |
2764
+ | \`get_price\` | TRADING | Yes | callTradingTool() |
2765
+ | \`get_deposit_addresses\` | TRADING | Yes | callTradingTool() |
2766
+ | \`transfer_usdc\` | TRADING | Yes | callTradingTool() |
2767
+ | \`search_markets\` | DISCOVERY | No (public key) | callDiscoveryTool() |
2768
+ | \`get_market_details\` | DISCOVERY | No | callDiscoveryTool() |
2769
+ | \`get_trending_markets\` | DISCOVERY | No | callDiscoveryTool() |
2770
+ | \`find_arbitrage\` | DISCOVERY | No | callDiscoveryTool() |
2771
+
2754
2772
  ### Key Trading Tools (require QUANTISH_API_KEY)
2773
+ URL: https://quantish-sdk-production.up.railway.app/mcp/execute
2774
+ Format: JSON-RPC 2.0 ({ jsonrpc, method, params, id })
2775
+
2755
2776
  - \`get_balances\`: Returns { usdc, nativeUsdc, matic } for EOA and Safe wallets
2756
2777
  - \`get_positions\`: Returns array of current share holdings with market info
2757
2778
  - \`place_order\`: Place order. Args: { conditionId, tokenId, side: "BUY"|"SELL", price: 0.01-0.99, size: number }
@@ -2763,6 +2784,8 @@ const result = JSON.parse(data.result.content[0].text);
2763
2784
  - \`transfer_usdc\`: Send USDC. Args: { toAddress, amount }
2764
2785
 
2765
2786
  ### Key Discovery Tools (free, no auth required)
2787
+ URL: https://quantish.live/mcp/execute
2788
+ Format: Simple ({ name, arguments }) - NOT JSON-RPC!
2766
2789
  Discovery uses a SIMPLER request format (not full JSON-RPC):
2767
2790
  \`\`\`javascript
2768
2791
  // Discovery API - uses simple { name, arguments } format
@@ -2861,14 +2884,24 @@ When generating ANY code that uses Quantish/MCP (bots, apps, scripts, APIs, etc.
2861
2884
 
2862
2885
  ### MANDATORY Requirements
2863
2886
 
2864
- 1. **ALWAYS include the callTool() helper function** - Copy it EXACTLY from the template above
2865
- 2. **ALWAYS use callTool() for ALL MCP operations** - Never use direct API calls to Polymarket
2866
- 3. **NEVER hardcode prices, market data, or API responses** - Always fetch live data via callTool()
2887
+ 1. **ALWAYS include BOTH callTradingTool() AND callDiscoveryTool() helper functions** - Copy them EXACTLY from the template
2888
+ 2. **USE THE CORRECT HELPER FOR EACH TOOL** - Check the tool-to-server mapping table above!
2889
+ - Trading tools (get_price, get_orderbook, place_order, etc.) \u2192 callTradingTool()
2890
+ - Discovery tools (search_markets, get_market_details, etc.) \u2192 callDiscoveryTool()
2891
+ 3. **NEVER hardcode prices, market data, or API responses** - Always fetch live data
2867
2892
  4. **NEVER comment out MCP calls** - All API calls must be real, working, executable code
2868
2893
  5. **ALWAYS create .env.example** - Document all required environment variables
2869
- 6. **ALWAYS validate QUANTISH_API_KEY exists** - Fail fast with clear error if missing
2894
+ 6. **ALWAYS validate QUANTISH_API_KEY exists** when using Trading tools - Fail fast with clear error if missing
2870
2895
  7. **ALWAYS use dotenv** - \`require('dotenv').config()\` at the top of every file
2871
2896
 
2897
+ ### \u26D4 NEVER DO WORKAROUNDS
2898
+
2899
+ - **NEVER try to "work around" missing tools** - If a tool requires auth, use auth
2900
+ - **NEVER substitute one tool for another** - get_market_details is NOT a replacement for get_price
2901
+ - **NEVER use the Discovery API for tools that require Trading API** - They are separate servers
2902
+ - **NEVER mock or simulate API responses** - Always make real API calls
2903
+ - **If a feature requires QUANTISH_API_KEY, tell the user they need one** - Don't try to avoid it
2904
+
2872
2905
  ### File Structure for ANY Application
2873
2906
 
2874
2907
  When creating an application, ALWAYS create these files:
@@ -3183,7 +3216,7 @@ var Agent = class {
3183
3216
  */
3184
3217
  async run(userMessage, options) {
3185
3218
  const maxIterations = this.config.maxIterations ?? 15;
3186
- const model = this.config.model ?? "claude-sonnet-4-5-20250929";
3219
+ const model = this.config.model ?? "claude-sonnet-4-20250514";
3187
3220
  const maxTokens = this.config.maxTokens ?? 8192;
3188
3221
  const systemPrompt = this.config.systemPrompt ?? DEFAULT_SYSTEM_PROMPT;
3189
3222
  const useStreaming = this.config.streaming ?? true;
@@ -3443,7 +3476,7 @@ ${userMessage}`;
3443
3476
  * Count tokens in current conversation (uses Anthropic's token counting API)
3444
3477
  */
3445
3478
  async countTokens() {
3446
- const model = this.config.model ?? "claude-sonnet-4-5-20250929";
3479
+ const model = this.config.model ?? "claude-sonnet-4-20250514";
3447
3480
  const systemPrompt = this.config.systemPrompt ?? DEFAULT_SYSTEM_PROMPT;
3448
3481
  const allTools = await this.getAllTools();
3449
3482
  try {
@@ -3514,7 +3547,7 @@ ${userMessage}`;
3514
3547
  * @returns Object with original/new token counts and the summary
3515
3548
  */
3516
3549
  async compactHistory() {
3517
- const model = this.config.model ?? "claude-sonnet-4-5-20250929";
3550
+ const model = this.config.model ?? "claude-sonnet-4-20250514";
3518
3551
  const systemPrompt = this.config.systemPrompt ?? DEFAULT_SYSTEM_PROMPT;
3519
3552
  const allTools = await this.getAllTools();
3520
3553
  if (this.conversationHistory.length < 2) {
@@ -4250,7 +4283,7 @@ program.command("config").description("View or edit configuration").option("-s,
4250
4283
  console.log(`QUANTISH_API_KEY=${all2.quantishApiKey}`);
4251
4284
  }
4252
4285
  console.log(`QUANTISH_MCP_URL=${all2.mcpServerUrl}`);
4253
- console.log(`QUANTISH_MODEL=${all2.model || "claude-sonnet-4-5-20250929"}`);
4286
+ console.log(`QUANTISH_MODEL=${all2.model || "claude-sonnet-4-20250514"}`);
4254
4287
  console.log();
4255
4288
  console.log(chalk3.dim("# Discovery MCP (public, read-only market data)"));
4256
4289
  console.log(`QUANTISH_DISCOVERY_URL=https://quantish.live/mcp`);
@@ -4271,7 +4304,7 @@ program.command("config").description("View or edit configuration").option("-s,
4271
4304
  tableRow("Quantish API Key", all.quantishApiKey ? `${all.quantishApiKey.slice(0, 12)}...` : chalk3.dim("Not set"));
4272
4305
  }
4273
4306
  tableRow("MCP Server URL", all.mcpServerUrl);
4274
- tableRow("Model", all.model || "claude-sonnet-4-5-20250929");
4307
+ tableRow("Model", all.model || "claude-sonnet-4-20250514");
4275
4308
  printDivider();
4276
4309
  console.log(chalk3.dim(`Config file: ${config.getConfigPath()}`));
4277
4310
  console.log();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quantish/agent",
3
- "version": "0.1.7",
3
+ "version": "0.1.9",
4
4
  "description": "AI-powered agent for building trading bots on Polymarket",
5
5
  "type": "module",
6
6
  "bin": {