opentool 0.8.28 → 0.9.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/README.md +11 -31
- package/dist/adapters/hyperliquid/index.d.ts +19 -1
- package/dist/adapters/hyperliquid/index.js +62 -2
- package/dist/adapters/hyperliquid/index.js.map +1 -1
- package/dist/cli/index.d.ts +0 -10
- package/dist/cli/index.js +0 -194
- package/dist/cli/index.js.map +1 -1
- package/dist/index.d.ts +29 -4
- package/dist/index.js +131 -3
- package/dist/index.js.map +1 -1
- package/dist/store/index.d.ts +12 -1
- package/dist/store/index.js +14 -2
- package/dist/store/index.js.map +1 -1
- package/package.json +9 -26
- package/templates/base/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -3,12 +3,12 @@ import { I as InternalToolDefinition, T as ToolResponse } from './validate-3WEA0
|
|
|
3
3
|
export { B as BuildConfig, m as BuildMetadata, p as ConnectedApp, C as CronSpec, s as GetHandler, H as HTTP_METHODS, f as HttpHandlerDefinition, e as HttpMethod, h as McpConfig, M as Metadata, N as NormalizedSchedule, P as PaymentConfig, t as PostHandler, S as ScheduleType, i as ServerConfig, q as TemplatePreviewProfile, j as Tool, o as ToolAsset, n as ToolCategory, d as ToolContent, k as ToolMetadataOverrides, x as ToolModule, u as ToolModuleGET, w as ToolModulePOST, r as ToolProfile, b as generateMetadata, g as generateMetadataCommand, l as loadAndValidateTools, v as validateCommand } from './validate-3WEA0Ezt.js';
|
|
4
4
|
export { CurrencySpec, DEFAULT_FACILITATOR, DefineX402PaymentConfig, EIP3009Authorization, PAYMENT_HEADERS, RequireX402PaymentOptions, RequireX402PaymentOutcome, RequireX402PaymentSuccess, SUPPORTED_CURRENCIES, X402BrowserClient, X402BrowserClientConfig, X402Client, X402ClientConfig, X402FacilitatorConfig, X402PayRequest, X402PayResult, X402Payment, X402PaymentContext, X402PaymentDefinition, X402PaymentRequiredError, X402VerificationResult, defineX402Payment, getX402PaymentContext, payX402, payX402WithWallet, requireX402Payment, withX402Payment } from './x402/index.js';
|
|
5
5
|
export { DEFAULT_CHAIN, DEFAULT_TOKENS, chains, getRpcUrl, registry, tokens, wallet, walletToolkit } from './wallet/index.js';
|
|
6
|
-
export { DEFAULT_HYPERLIQUID_MARKET_SLIPPAGE_BPS, HyperliquidAbstraction, HyperliquidAccountMode, HyperliquidApiError, HyperliquidApproveBuilderFeeOptions, HyperliquidApproveBuilderFeeResponse, HyperliquidBuilderApprovalError, HyperliquidBuilderApprovalRecordInput, HyperliquidBuilderFee, HyperliquidChain, HyperliquidClearinghouseState, HyperliquidDepositResult, HyperliquidEnvironment, HyperliquidExchangeClient, HyperliquidExchangeResponse, HyperliquidGrouping, HyperliquidGuardError, HyperliquidInfoClient, HyperliquidMarketIdentityInput, HyperliquidMarketType, HyperliquidOrderIntent, HyperliquidOrderOptions, HyperliquidOrderResponse, HyperliquidOrderStatus, HyperliquidPerpMarketInfo, HyperliquidProfileAsset, HyperliquidProfileAssetInput, HyperliquidProfileChain, HyperliquidSpotMarketInfo, HyperliquidStoreNetwork, HyperliquidTermsError, HyperliquidTermsRecordInput, HyperliquidTickSize, HyperliquidTimeInForce, HyperliquidTriggerOptions, HyperliquidTriggerType, HyperliquidWithdrawResult, MarketIdentity, NonceSource, __hyperliquidInternals, __hyperliquidMarketDataInternals, approveHyperliquidBuilderFee, batchModifyHyperliquidOrders, buildHyperliquidMarketIdentity, buildHyperliquidProfileAssets, buildHyperliquidSpotUsdPriceMap, cancelAllHyperliquidOrders, cancelHyperliquidOrders, cancelHyperliquidOrdersByCloid, cancelHyperliquidTwapOrder, computeHyperliquidMarketIocLimitPrice, createHyperliquidSubAccount, createMonotonicNonceFactory, depositToHyperliquidBridge, extractHyperliquidDex, extractHyperliquidOrderIds, fetchHyperliquidAllMids, fetchHyperliquidAssetCtxs, fetchHyperliquidClearinghouseState, fetchHyperliquidFrontendOpenOrders, fetchHyperliquidHistoricalOrders, fetchHyperliquidMeta, fetchHyperliquidMetaAndAssetCtxs, fetchHyperliquidOpenOrders, fetchHyperliquidOrderStatus, fetchHyperliquidPerpMarketInfo, fetchHyperliquidPreTransferCheck, fetchHyperliquidSizeDecimals, fetchHyperliquidSpotAccountValue, fetchHyperliquidSpotAssetCtxs, fetchHyperliquidSpotClearinghouseState, fetchHyperliquidSpotMarketInfo, fetchHyperliquidSpotMeta, fetchHyperliquidSpotMetaAndAssetCtxs, fetchHyperliquidSpotTickSize, fetchHyperliquidSpotUsdPriceMap, fetchHyperliquidTickSize, fetchHyperliquidUserFills, fetchHyperliquidUserFillsByTime, fetchHyperliquidUserRateLimit, formatHyperliquidMarketablePrice, formatHyperliquidOrderSize, formatHyperliquidPrice, formatHyperliquidSize, getHyperliquidMaxBuilderFee, isHyperliquidSpotSymbol, modifyHyperliquidOrder, normalizeHyperliquidBaseSymbol, normalizeHyperliquidMetaSymbol, normalizeSpotTokenName, parseSpotPairSymbol, placeHyperliquidOrder, placeHyperliquidTwapOrder, readHyperliquidAccountValue, readHyperliquidNumber, readHyperliquidPerpPosition, readHyperliquidPerpPositionSize, readHyperliquidSpotAccountValue, readHyperliquidSpotBalance, readHyperliquidSpotBalanceSize, recordHyperliquidBuilderApproval, recordHyperliquidTermsAcceptance, reserveHyperliquidRequestWeight, resolveHyperliquidAbstractionFromMode, resolveHyperliquidChain, resolveHyperliquidChainConfig, resolveHyperliquidErrorDetail, resolveHyperliquidOrderRef, resolveHyperliquidOrderSymbol, resolveHyperliquidPair, resolveHyperliquidProfileChain, resolveHyperliquidRpcEnvVar, resolveHyperliquidStoreNetwork, resolveHyperliquidSymbol, resolveSpotMidCandidates, resolveSpotTokenCandidates, roundHyperliquidPriceToTick, scheduleHyperliquidCancel, sendHyperliquidSpot, setHyperliquidAccountAbstractionMode, setHyperliquidDexAbstraction, setHyperliquidPortfolioMargin, transferHyperliquidSubAccount, updateHyperliquidIsolatedMargin, updateHyperliquidLeverage, withdrawFromHyperliquid } from './adapters/hyperliquid/index.js';
|
|
6
|
+
export { DEFAULT_HYPERLIQUID_MARKET_SLIPPAGE_BPS, HyperliquidAbstraction, HyperliquidAccountMode, HyperliquidApiError, HyperliquidApproveBuilderFeeOptions, HyperliquidApproveBuilderFeeResponse, HyperliquidBar, HyperliquidBarResolution, HyperliquidBuilderApprovalError, HyperliquidBuilderApprovalRecordInput, HyperliquidBuilderFee, HyperliquidChain, HyperliquidClearinghouseState, HyperliquidDepositResult, HyperliquidEnvironment, HyperliquidExchangeClient, HyperliquidExchangeResponse, HyperliquidGrouping, HyperliquidGuardError, HyperliquidInfoClient, HyperliquidMarketIdentityInput, HyperliquidMarketType, HyperliquidOrderIntent, HyperliquidOrderOptions, HyperliquidOrderResponse, HyperliquidOrderStatus, HyperliquidPerpMarketInfo, HyperliquidProfileAsset, HyperliquidProfileAssetInput, HyperliquidProfileChain, HyperliquidSpotMarketInfo, HyperliquidStoreNetwork, HyperliquidTermsError, HyperliquidTermsRecordInput, HyperliquidTickSize, HyperliquidTimeInForce, HyperliquidTriggerOptions, HyperliquidTriggerType, HyperliquidWithdrawResult, MarketIdentity, NonceSource, __hyperliquidInternals, __hyperliquidMarketDataInternals, approveHyperliquidBuilderFee, batchModifyHyperliquidOrders, buildHyperliquidMarketIdentity, buildHyperliquidProfileAssets, buildHyperliquidSpotUsdPriceMap, cancelAllHyperliquidOrders, cancelHyperliquidOrders, cancelHyperliquidOrdersByCloid, cancelHyperliquidTwapOrder, computeHyperliquidMarketIocLimitPrice, createHyperliquidSubAccount, createMonotonicNonceFactory, depositToHyperliquidBridge, extractHyperliquidDex, extractHyperliquidOrderIds, fetchHyperliquidAllMids, fetchHyperliquidAssetCtxs, fetchHyperliquidBars, fetchHyperliquidClearinghouseState, fetchHyperliquidFrontendOpenOrders, fetchHyperliquidHistoricalOrders, fetchHyperliquidMeta, fetchHyperliquidMetaAndAssetCtxs, fetchHyperliquidOpenOrders, fetchHyperliquidOrderStatus, fetchHyperliquidPerpMarketInfo, fetchHyperliquidPreTransferCheck, fetchHyperliquidSizeDecimals, fetchHyperliquidSpotAccountValue, fetchHyperliquidSpotAssetCtxs, fetchHyperliquidSpotClearinghouseState, fetchHyperliquidSpotMarketInfo, fetchHyperliquidSpotMeta, fetchHyperliquidSpotMetaAndAssetCtxs, fetchHyperliquidSpotTickSize, fetchHyperliquidSpotUsdPriceMap, fetchHyperliquidTickSize, fetchHyperliquidUserFills, fetchHyperliquidUserFillsByTime, fetchHyperliquidUserRateLimit, formatHyperliquidMarketablePrice, formatHyperliquidOrderSize, formatHyperliquidPrice, formatHyperliquidSize, getHyperliquidMaxBuilderFee, isHyperliquidSpotSymbol, modifyHyperliquidOrder, normalizeHyperliquidBaseSymbol, normalizeHyperliquidMetaSymbol, normalizeSpotTokenName, parseSpotPairSymbol, placeHyperliquidOrder, placeHyperliquidTwapOrder, readHyperliquidAccountValue, readHyperliquidNumber, readHyperliquidPerpPosition, readHyperliquidPerpPositionSize, readHyperliquidSpotAccountValue, readHyperliquidSpotBalance, readHyperliquidSpotBalanceSize, recordHyperliquidBuilderApproval, recordHyperliquidTermsAcceptance, reserveHyperliquidRequestWeight, resolveHyperliquidAbstractionFromMode, resolveHyperliquidChain, resolveHyperliquidChainConfig, resolveHyperliquidErrorDetail, resolveHyperliquidOrderRef, resolveHyperliquidOrderSymbol, resolveHyperliquidPair, resolveHyperliquidProfileChain, resolveHyperliquidRpcEnvVar, resolveHyperliquidStoreNetwork, resolveHyperliquidSymbol, resolveSpotMidCandidates, resolveSpotTokenCandidates, roundHyperliquidPriceToTick, scheduleHyperliquidCancel, sendHyperliquidSpot, setHyperliquidAccountAbstractionMode, setHyperliquidDexAbstraction, setHyperliquidPortfolioMargin, transferHyperliquidSubAccount, updateHyperliquidIsolatedMargin, updateHyperliquidLeverage, withdrawFromHyperliquid } from './adapters/hyperliquid/index.js';
|
|
7
7
|
import { c as WalletFullContext } from './types-BVLpaY4O.js';
|
|
8
8
|
export { C as ChainMetadata, i as ChainReference, a as ChainTokenMap, H as Hex, g as HexAddress, R as RpcProviderOptions, h as RpcUrlResolver, T as TokenMetadata, l as TurnkeyOptions, k as TurnkeySignWith, r as WalletBaseContext, s as WalletContext, n as WalletOptions, m as WalletOptionsBase, b as WalletPrivateKeyOptions, j as WalletProviderType, f as WalletReadonlyContext, e as WalletReadonlyOptions, W as WalletRegistry, o as WalletSendTransactionParams, q as WalletSignerContext, p as WalletTransferParams, d as WalletTurnkeyOptions } from './types-BVLpaY4O.js';
|
|
9
9
|
export { AIAbortError, AIClientConfig, AIError, AIFetchError, AIRequestMetadata, AIResponseError, ChatCompletionChoice, ChatCompletionLogProbs, ChatCompletionResponse, ChatCompletionUsage, ChatMessage, ChatMessageContentPart, ChatMessageContentPartImageUrl, ChatMessageContentPartText, ChatMessageRole, DEFAULT_BASE_URL, DEFAULT_MODEL, DEFAULT_TIMEOUT_MS, FunctionToolDefinition, GenerateTextOptions, GenerateTextResult, GenerationParameters, JsonSchema, ResolvedAIClientConfig, ResponseErrorDetails, StreamTextOptions, StreamTextResult, StreamingEventHandlers, ToolChoice, ToolDefinition, ToolExecutionPolicy, WEBSEARCH_TOOL_DEFINITION, WEBSEARCH_TOOL_NAME, WebSearchOptions, createAIClient, ensureTextContent, flattenMessageContent, generateText, getModelConfig, isStreamingSupported, isToolCallingSupported, listModels, normalizeModelName, resolveConfig, resolveToolset, streamText } from './ai/index.js';
|
|
10
|
-
export { AgentDigestRequest, MyToolsResponse, StoreAction, StoreError, StoreEventInput, StoreEventLevel, StoreOptions, StoreResponse, StoreRetrieveParams, StoreRetrieveResult, ToolExecuteRequest, ToolExecuteResponse, executeTool, getMyPerformance, getMyTools, postAgentDigest, retrieve, store } from './store/index.js';
|
|
11
|
-
import { ZodSchema } from 'zod';
|
|
10
|
+
export { AgentDigestRequest, MyToolsResponse, StoreAction, StoreError, StoreEventInput, StoreEventLevel, StoreMode, StoreOptions, StoreResponse, StoreRetrieveParams, StoreRetrieveResult, StoreSimulationConfig, ToolExecuteRequest, ToolExecuteResponse, executeTool, getMyPerformance, getMyTools, postAgentDigest, retrieve, store } from './store/index.js';
|
|
11
|
+
import { z, ZodSchema } from 'zod';
|
|
12
12
|
import 'viem';
|
|
13
13
|
import 'viem/accounts';
|
|
14
14
|
|
|
@@ -336,6 +336,31 @@ declare function fetchPolymarketPriceHistory(params: {
|
|
|
336
336
|
environment?: PolymarketEnvironment;
|
|
337
337
|
}): Promise<PolymarketPriceHistoryPoint[]>;
|
|
338
338
|
|
|
339
|
+
declare const backtestDecisionRequestSchema: z.ZodObject<{
|
|
340
|
+
mode: z.ZodLiteral<"backtest_decisions">;
|
|
341
|
+
source: z.ZodOptional<z.ZodString>;
|
|
342
|
+
symbol: z.ZodOptional<z.ZodString>;
|
|
343
|
+
lookbackDays: z.ZodOptional<z.ZodNumber>;
|
|
344
|
+
timeframeStart: z.ZodOptional<z.ZodString>;
|
|
345
|
+
timeframeEnd: z.ZodOptional<z.ZodString>;
|
|
346
|
+
from: z.ZodOptional<z.ZodNumber>;
|
|
347
|
+
to: z.ZodOptional<z.ZodNumber>;
|
|
348
|
+
initialEquityUsd: z.ZodOptional<z.ZodNumber>;
|
|
349
|
+
}, z.core.$strict>;
|
|
350
|
+
type BacktestDecisionRequest = z.infer<typeof backtestDecisionRequestSchema>;
|
|
351
|
+
type BacktestResolution = "1" | "5" | "15" | "30" | "60" | "240" | "1D" | "1W";
|
|
352
|
+
declare function parseTimeToSeconds(value: unknown): number | null;
|
|
353
|
+
declare function resolutionToSeconds(resolution: BacktestResolution): number;
|
|
354
|
+
declare function estimateCountBack(params: {
|
|
355
|
+
fallback: number;
|
|
356
|
+
lookbackDays?: number;
|
|
357
|
+
resolution: BacktestResolution;
|
|
358
|
+
fromSeconds?: number;
|
|
359
|
+
toSeconds?: number;
|
|
360
|
+
minCountBack?: number;
|
|
361
|
+
bufferBars?: number;
|
|
362
|
+
}): number;
|
|
363
|
+
|
|
339
364
|
interface CreateMcpAdapterOptions {
|
|
340
365
|
name: string;
|
|
341
366
|
schema?: ZodSchema;
|
|
@@ -348,4 +373,4 @@ interface CreateMcpAdapterOptions {
|
|
|
348
373
|
declare function createMcpAdapter(options: CreateMcpAdapterOptions): (rawArguments: unknown) => Promise<ToolResponse>;
|
|
349
374
|
declare function responseToToolResponse(response: Response): Promise<ToolResponse>;
|
|
350
375
|
|
|
351
|
-
export { InternalToolDefinition, POLYMARKET_CHAIN_ID, POLYMARKET_CLOB_AUTH_DOMAIN, POLYMARKET_CLOB_DOMAIN, POLYMARKET_ENDPOINTS, POLYMARKET_EXCHANGE_ADDRESSES, type PolymarketApiCredentials, PolymarketApiError, type PolymarketApiKeyResponse, PolymarketAuthError, type PolymarketEnvironment, PolymarketExchangeClient, PolymarketInfoClient, type PolymarketMarket, type PolymarketOrderIntent, type PolymarketOrderType, type PolymarketOrderbook, type PolymarketPlaceOrderResponse, type PolymarketPriceHistoryPoint, type PolymarketSide, type PolymarketSignatureType, type PolymarketSignedOrderPayload, ToolResponse, WalletFullContext, buildHmacSignature, buildL1Headers, buildL2Headers, buildPolymarketOrderAmounts, buildSignedOrderPayload, cancelAllPolymarketOrders, cancelMarketPolymarketOrders, cancelPolymarketOrder, cancelPolymarketOrders, createDevServer, createMcpAdapter, createPolymarketApiKey, createStdioServer, derivePolymarketApiKey, fetchPolymarketMarket, fetchPolymarketMarkets, fetchPolymarketMidpoint, fetchPolymarketOrderbook, fetchPolymarketPrice, fetchPolymarketPriceHistory, normalizeNumberArrayish, normalizeStringArrayish, placePolymarketOrder, resolveExchangeAddress, resolvePolymarketBaseUrl, resolveRuntimePath, responseToToolResponse };
|
|
376
|
+
export { type BacktestDecisionRequest, type BacktestResolution, InternalToolDefinition, POLYMARKET_CHAIN_ID, POLYMARKET_CLOB_AUTH_DOMAIN, POLYMARKET_CLOB_DOMAIN, POLYMARKET_ENDPOINTS, POLYMARKET_EXCHANGE_ADDRESSES, type PolymarketApiCredentials, PolymarketApiError, type PolymarketApiKeyResponse, PolymarketAuthError, type PolymarketEnvironment, PolymarketExchangeClient, PolymarketInfoClient, type PolymarketMarket, type PolymarketOrderIntent, type PolymarketOrderType, type PolymarketOrderbook, type PolymarketPlaceOrderResponse, type PolymarketPriceHistoryPoint, type PolymarketSide, type PolymarketSignatureType, type PolymarketSignedOrderPayload, ToolResponse, WalletFullContext, backtestDecisionRequestSchema, buildHmacSignature, buildL1Headers, buildL2Headers, buildPolymarketOrderAmounts, buildSignedOrderPayload, cancelAllPolymarketOrders, cancelMarketPolymarketOrders, cancelPolymarketOrder, cancelPolymarketOrders, createDevServer, createMcpAdapter, createPolymarketApiKey, createStdioServer, derivePolymarketApiKey, estimateCountBack, fetchPolymarketMarket, fetchPolymarketMarkets, fetchPolymarketMidpoint, fetchPolymarketOrderbook, fetchPolymarketPrice, fetchPolymarketPriceHistory, normalizeNumberArrayish, normalizeStringArrayish, parseTimeToSeconds, placePolymarketOrder, resolutionToSeconds, resolveExchangeAddress, resolvePolymarketBaseUrl, resolveRuntimePath, responseToToolResponse };
|
package/dist/index.js
CHANGED
|
@@ -1761,8 +1761,14 @@ async function requestJson(url, options, init) {
|
|
|
1761
1761
|
}
|
|
1762
1762
|
async function store(input, options) {
|
|
1763
1763
|
const normalizedInput = normalizeStoreInput(input);
|
|
1764
|
+
const mode = normalizedInput.mode ?? "live";
|
|
1764
1765
|
const eventLevel = normalizedInput.eventLevel;
|
|
1765
1766
|
const normalizedAction = normalizeAction(normalizedInput.action);
|
|
1767
|
+
if (mode === "backtest" && !normalizedInput.backtestRunId) {
|
|
1768
|
+
throw new StoreError(
|
|
1769
|
+
`backtestRunId is required when mode is "backtest"`
|
|
1770
|
+
);
|
|
1771
|
+
}
|
|
1766
1772
|
if (eventLevel === "execution" || eventLevel === "lifecycle") {
|
|
1767
1773
|
if (!normalizedAction || !EXECUTION_ACTIONS_SET.has(normalizedAction)) {
|
|
1768
1774
|
throw new StoreError(
|
|
@@ -1782,7 +1788,8 @@ async function store(input, options) {
|
|
|
1782
1788
|
);
|
|
1783
1789
|
}
|
|
1784
1790
|
const { baseUrl, apiKey, fetchFn } = resolveConfig(options);
|
|
1785
|
-
const
|
|
1791
|
+
const path8 = mode === "backtest" ? "/apps/backtests/tx" : "/apps/positions/tx";
|
|
1792
|
+
const url = `${baseUrl}${path8}`;
|
|
1786
1793
|
let response;
|
|
1787
1794
|
try {
|
|
1788
1795
|
response = await fetchFn(url, {
|
|
@@ -1821,7 +1828,9 @@ async function store(input, options) {
|
|
|
1821
1828
|
}
|
|
1822
1829
|
async function retrieve(params, options) {
|
|
1823
1830
|
const { baseUrl, apiKey, fetchFn } = resolveConfig(options);
|
|
1824
|
-
const
|
|
1831
|
+
const mode = params?.mode ?? "live";
|
|
1832
|
+
const path8 = mode === "backtest" ? "/apps/backtests/tx" : "/apps/positions/tx";
|
|
1833
|
+
const url = new URL(`${baseUrl}${path8}`);
|
|
1825
1834
|
if (params?.source) url.searchParams.set("source", params.source);
|
|
1826
1835
|
if (params?.walletAddress) url.searchParams.set("walletAddress", params.walletAddress);
|
|
1827
1836
|
if (params?.symbol) url.searchParams.set("symbol", params.symbol);
|
|
@@ -1831,6 +1840,9 @@ async function retrieve(params, options) {
|
|
|
1831
1840
|
if (typeof params?.limit === "number") url.searchParams.set("limit", params.limit.toString());
|
|
1832
1841
|
if (params?.cursor) url.searchParams.set("cursor", params.cursor);
|
|
1833
1842
|
if (params?.history) url.searchParams.set("history", "true");
|
|
1843
|
+
if (params?.backtestRunId) {
|
|
1844
|
+
url.searchParams.set("backtestRunId", params.backtestRunId);
|
|
1845
|
+
}
|
|
1834
1846
|
let response;
|
|
1835
1847
|
try {
|
|
1836
1848
|
response = await fetchFn(url.toString(), {
|
|
@@ -3951,6 +3963,28 @@ function readHyperliquidSpotAccountValue(params) {
|
|
|
3951
3963
|
// src/adapters/hyperliquid/market-data.ts
|
|
3952
3964
|
var META_CACHE_TTL_MS = 5 * 60 * 1e3;
|
|
3953
3965
|
var allMidsCache = /* @__PURE__ */ new Map();
|
|
3966
|
+
function resolveGatewayBase(override) {
|
|
3967
|
+
const value = override ?? process.env.OPENPOND_GATEWAY_URL ?? null;
|
|
3968
|
+
if (typeof value !== "string") {
|
|
3969
|
+
return null;
|
|
3970
|
+
}
|
|
3971
|
+
const trimmed = value.trim();
|
|
3972
|
+
if (!trimmed) {
|
|
3973
|
+
return null;
|
|
3974
|
+
}
|
|
3975
|
+
return trimmed.replace(/\/$/, "");
|
|
3976
|
+
}
|
|
3977
|
+
function normalizeGatewaySymbol(value) {
|
|
3978
|
+
const trimmed = value.trim();
|
|
3979
|
+
if (!trimmed) return trimmed;
|
|
3980
|
+
const idx = trimmed.indexOf(":");
|
|
3981
|
+
if (idx > 0) {
|
|
3982
|
+
const dex = trimmed.slice(0, idx).toLowerCase();
|
|
3983
|
+
const rest = trimmed.slice(idx + 1);
|
|
3984
|
+
return `${dex}:${rest.toUpperCase()}`;
|
|
3985
|
+
}
|
|
3986
|
+
return trimmed.toUpperCase();
|
|
3987
|
+
}
|
|
3954
3988
|
function gcd(a, b) {
|
|
3955
3989
|
let left = a < 0n ? -a : a;
|
|
3956
3990
|
let right = b < 0n ? -b : b;
|
|
@@ -4071,6 +4105,37 @@ async function fetchHyperliquidAllMids(environment) {
|
|
|
4071
4105
|
allMidsCache.set(cacheKey, { fetchedAt: Date.now(), mids: json });
|
|
4072
4106
|
return json;
|
|
4073
4107
|
}
|
|
4108
|
+
async function fetchHyperliquidBars(params) {
|
|
4109
|
+
const gatewayBase = resolveGatewayBase(params.gatewayBase);
|
|
4110
|
+
if (!gatewayBase) {
|
|
4111
|
+
throw new Error("OPENPOND_GATEWAY_URL is required.");
|
|
4112
|
+
}
|
|
4113
|
+
const normalizedCountBack = Math.max(1, Math.trunc(params.countBack));
|
|
4114
|
+
if (!Number.isFinite(normalizedCountBack) || normalizedCountBack <= 0) {
|
|
4115
|
+
throw new Error("countBack must be a positive integer.");
|
|
4116
|
+
}
|
|
4117
|
+
const url = new URL(`${gatewayBase}/v1/hyperliquid/bars`);
|
|
4118
|
+
url.searchParams.set("symbol", normalizeGatewaySymbol(params.symbol));
|
|
4119
|
+
url.searchParams.set("resolution", params.resolution);
|
|
4120
|
+
url.searchParams.set("countBack", normalizedCountBack.toString());
|
|
4121
|
+
if (typeof params.fromSeconds === "number" && Number.isFinite(params.fromSeconds)) {
|
|
4122
|
+
url.searchParams.set("from", Math.max(0, Math.trunc(params.fromSeconds)).toString());
|
|
4123
|
+
}
|
|
4124
|
+
if (typeof params.toSeconds === "number" && Number.isFinite(params.toSeconds)) {
|
|
4125
|
+
url.searchParams.set("to", Math.max(0, Math.trunc(params.toSeconds)).toString());
|
|
4126
|
+
}
|
|
4127
|
+
const response = await fetch(url.toString());
|
|
4128
|
+
if (!response.ok) {
|
|
4129
|
+
throw new Error(`Gateway error (${response.status})`);
|
|
4130
|
+
}
|
|
4131
|
+
const data = await response.json().catch(() => null);
|
|
4132
|
+
const bars = Array.isArray(data?.bars) ? data.bars : [];
|
|
4133
|
+
return bars.filter((bar) => {
|
|
4134
|
+
if (!bar || typeof bar !== "object") return false;
|
|
4135
|
+
const record = bar;
|
|
4136
|
+
return typeof record.close === "number" && Number.isFinite(record.close) && typeof record.time === "number" && Number.isFinite(record.time);
|
|
4137
|
+
});
|
|
4138
|
+
}
|
|
4074
4139
|
async function fetchHyperliquidTickSize(params) {
|
|
4075
4140
|
return fetchHyperliquidTickSizeForCoin(params.environment, params.symbol);
|
|
4076
4141
|
}
|
|
@@ -6315,6 +6380,69 @@ function toAbortError(reason) {
|
|
|
6315
6380
|
}
|
|
6316
6381
|
return new AIAbortError(String(reason ?? "AI request aborted"));
|
|
6317
6382
|
}
|
|
6383
|
+
var backtestDecisionRequestSchema = z.object({
|
|
6384
|
+
mode: z.literal("backtest_decisions"),
|
|
6385
|
+
source: z.string().min(1).optional(),
|
|
6386
|
+
symbol: z.string().min(1).optional(),
|
|
6387
|
+
lookbackDays: z.number().positive().optional(),
|
|
6388
|
+
timeframeStart: z.string().optional(),
|
|
6389
|
+
timeframeEnd: z.string().optional(),
|
|
6390
|
+
from: z.number().int().nonnegative().optional(),
|
|
6391
|
+
to: z.number().int().nonnegative().optional(),
|
|
6392
|
+
initialEquityUsd: z.number().positive().optional()
|
|
6393
|
+
}).strict();
|
|
6394
|
+
var RESOLUTION_SECONDS = {
|
|
6395
|
+
"1": 60,
|
|
6396
|
+
"5": 300,
|
|
6397
|
+
"15": 900,
|
|
6398
|
+
"30": 1800,
|
|
6399
|
+
"60": 3600,
|
|
6400
|
+
"240": 14400,
|
|
6401
|
+
"1D": 86400,
|
|
6402
|
+
"1W": 604800
|
|
6403
|
+
};
|
|
6404
|
+
function parseTimeToSeconds(value) {
|
|
6405
|
+
if (typeof value === "number" && Number.isFinite(value)) {
|
|
6406
|
+
return Math.max(0, Math.trunc(value));
|
|
6407
|
+
}
|
|
6408
|
+
if (typeof value === "string" && value.trim().length > 0) {
|
|
6409
|
+
const trimmed = value.trim();
|
|
6410
|
+
if (/^-?(?:\d+\.?\d*|\.\d+)$/.test(trimmed)) {
|
|
6411
|
+
const numeric = Number.parseFloat(trimmed);
|
|
6412
|
+
return Math.max(0, Math.trunc(numeric));
|
|
6413
|
+
}
|
|
6414
|
+
const parsedDate = new Date(value);
|
|
6415
|
+
if (!Number.isNaN(parsedDate.getTime())) {
|
|
6416
|
+
return Math.max(0, Math.trunc(parsedDate.getTime() / 1e3));
|
|
6417
|
+
}
|
|
6418
|
+
}
|
|
6419
|
+
return null;
|
|
6420
|
+
}
|
|
6421
|
+
function resolutionToSeconds(resolution) {
|
|
6422
|
+
return RESOLUTION_SECONDS[resolution];
|
|
6423
|
+
}
|
|
6424
|
+
function estimateCountBack(params) {
|
|
6425
|
+
const {
|
|
6426
|
+
fallback,
|
|
6427
|
+
lookbackDays,
|
|
6428
|
+
resolution,
|
|
6429
|
+
fromSeconds,
|
|
6430
|
+
toSeconds,
|
|
6431
|
+
minCountBack = 50,
|
|
6432
|
+
bufferBars = 5
|
|
6433
|
+
} = params;
|
|
6434
|
+
if (typeof lookbackDays === "number" && Number.isFinite(lookbackDays) && lookbackDays > 0) {
|
|
6435
|
+
const interval = resolutionToSeconds(resolution);
|
|
6436
|
+
const bars = Math.ceil(lookbackDays * 86400 / interval);
|
|
6437
|
+
return Math.max(minCountBack, bars + bufferBars);
|
|
6438
|
+
}
|
|
6439
|
+
if (typeof fromSeconds === "number" && Number.isFinite(fromSeconds) && typeof toSeconds === "number" && Number.isFinite(toSeconds) && toSeconds > fromSeconds) {
|
|
6440
|
+
const interval = resolutionToSeconds(resolution);
|
|
6441
|
+
const bars = Math.ceil((toSeconds - fromSeconds) / interval);
|
|
6442
|
+
return Math.max(minCountBack, bars + bufferBars);
|
|
6443
|
+
}
|
|
6444
|
+
return fallback;
|
|
6445
|
+
}
|
|
6318
6446
|
var METADATA_SPEC_VERSION = "1.1.0";
|
|
6319
6447
|
var McpAnnotationsSchema = z.object({
|
|
6320
6448
|
title: z.string().optional(),
|
|
@@ -7393,6 +7521,6 @@ function timestamp() {
|
|
|
7393
7521
|
return (/* @__PURE__ */ new Date()).toISOString().replace("T", " ").slice(0, 19);
|
|
7394
7522
|
}
|
|
7395
7523
|
|
|
7396
|
-
export { AIAbortError, AIError, AIFetchError, AIResponseError, DEFAULT_BASE_URL, DEFAULT_CHAIN, DEFAULT_FACILITATOR, DEFAULT_HYPERLIQUID_MARKET_SLIPPAGE_BPS, DEFAULT_MODEL, DEFAULT_TIMEOUT_MS, DEFAULT_TOKENS, HTTP_METHODS2 as HTTP_METHODS, HyperliquidApiError, HyperliquidBuilderApprovalError, HyperliquidExchangeClient, HyperliquidGuardError, HyperliquidInfoClient, HyperliquidTermsError, PAYMENT_HEADERS, POLYMARKET_CHAIN_ID, POLYMARKET_CLOB_AUTH_DOMAIN, POLYMARKET_CLOB_DOMAIN, POLYMARKET_ENDPOINTS, POLYMARKET_EXCHANGE_ADDRESSES, PolymarketApiError, PolymarketAuthError, PolymarketExchangeClient, PolymarketInfoClient, SUPPORTED_CURRENCIES, StoreError, WEBSEARCH_TOOL_DEFINITION, WEBSEARCH_TOOL_NAME, X402BrowserClient, X402Client, X402PaymentRequiredError, __hyperliquidInternals, __hyperliquidMarketDataInternals, approveHyperliquidBuilderFee, batchModifyHyperliquidOrders, buildHmacSignature, buildHyperliquidMarketIdentity, buildHyperliquidProfileAssets, buildHyperliquidSpotUsdPriceMap, buildL1Headers, buildL2Headers, buildPolymarketOrderAmounts, buildSignedOrderPayload, cancelAllHyperliquidOrders, cancelAllPolymarketOrders, cancelHyperliquidOrders, cancelHyperliquidOrdersByCloid, cancelHyperliquidTwapOrder, cancelMarketPolymarketOrders, cancelPolymarketOrder, cancelPolymarketOrders, chains, computeHyperliquidMarketIocLimitPrice, createAIClient, createDevServer, createHyperliquidSubAccount, createMcpAdapter, createMonotonicNonceFactory, createPolymarketApiKey, createStdioServer, defineX402Payment, depositToHyperliquidBridge, derivePolymarketApiKey, ensureTextContent, executeTool, extractHyperliquidDex, extractHyperliquidOrderIds, fetchHyperliquidAllMids, fetchHyperliquidAssetCtxs, fetchHyperliquidClearinghouseState, fetchHyperliquidFrontendOpenOrders, fetchHyperliquidHistoricalOrders, fetchHyperliquidMeta, fetchHyperliquidMetaAndAssetCtxs, fetchHyperliquidOpenOrders, fetchHyperliquidOrderStatus, fetchHyperliquidPerpMarketInfo, fetchHyperliquidPreTransferCheck, fetchHyperliquidSizeDecimals, fetchHyperliquidSpotAccountValue, fetchHyperliquidSpotAssetCtxs, fetchHyperliquidSpotClearinghouseState, fetchHyperliquidSpotMarketInfo, fetchHyperliquidSpotMeta, fetchHyperliquidSpotMetaAndAssetCtxs, fetchHyperliquidSpotTickSize, fetchHyperliquidSpotUsdPriceMap, fetchHyperliquidTickSize, fetchHyperliquidUserFills, fetchHyperliquidUserFillsByTime, fetchHyperliquidUserRateLimit, fetchPolymarketMarket, fetchPolymarketMarkets, fetchPolymarketMidpoint, fetchPolymarketOrderbook, fetchPolymarketPrice, fetchPolymarketPriceHistory, flattenMessageContent, formatHyperliquidMarketablePrice, formatHyperliquidOrderSize, formatHyperliquidPrice, formatHyperliquidSize, generateMetadata, generateMetadataCommand, generateText, getHyperliquidMaxBuilderFee, getModelConfig, getMyPerformance, getMyTools, getRpcUrl, getX402PaymentContext, isHyperliquidSpotSymbol, isStreamingSupported, isToolCallingSupported, listModels, loadAndValidateTools, modifyHyperliquidOrder, normalizeHyperliquidBaseSymbol, normalizeHyperliquidMetaSymbol, normalizeModelName, normalizeNumberArrayish, normalizeSpotTokenName2 as normalizeSpotTokenName, normalizeStringArrayish, parseSpotPairSymbol, payX402, payX402WithWallet, placeHyperliquidOrder, placeHyperliquidTwapOrder, placePolymarketOrder, postAgentDigest, readHyperliquidAccountValue, readHyperliquidNumber, readHyperliquidPerpPosition, readHyperliquidPerpPositionSize, readHyperliquidSpotAccountValue, readHyperliquidSpotBalance, readHyperliquidSpotBalanceSize, recordHyperliquidBuilderApproval, recordHyperliquidTermsAcceptance, registry, requireX402Payment, reserveHyperliquidRequestWeight, resolveConfig2 as resolveConfig, resolveExchangeAddress, resolveHyperliquidAbstractionFromMode, resolveHyperliquidChain, resolveHyperliquidChainConfig, resolveHyperliquidErrorDetail, resolveHyperliquidOrderRef, resolveHyperliquidOrderSymbol, resolveHyperliquidPair, resolveHyperliquidProfileChain, resolveHyperliquidRpcEnvVar, resolveHyperliquidStoreNetwork, resolveHyperliquidSymbol, resolvePolymarketBaseUrl, resolveRuntimePath, resolveSpotMidCandidates, resolveSpotTokenCandidates, resolveToolset, responseToToolResponse, retrieve, roundHyperliquidPriceToTick, scheduleHyperliquidCancel, sendHyperliquidSpot, setHyperliquidAccountAbstractionMode, setHyperliquidDexAbstraction, setHyperliquidPortfolioMargin, store, streamText, tokens, transferHyperliquidSubAccount, updateHyperliquidIsolatedMargin, updateHyperliquidLeverage, validateCommand, wallet, walletToolkit, withX402Payment, withdrawFromHyperliquid };
|
|
7524
|
+
export { AIAbortError, AIError, AIFetchError, AIResponseError, DEFAULT_BASE_URL, DEFAULT_CHAIN, DEFAULT_FACILITATOR, DEFAULT_HYPERLIQUID_MARKET_SLIPPAGE_BPS, DEFAULT_MODEL, DEFAULT_TIMEOUT_MS, DEFAULT_TOKENS, HTTP_METHODS2 as HTTP_METHODS, HyperliquidApiError, HyperliquidBuilderApprovalError, HyperliquidExchangeClient, HyperliquidGuardError, HyperliquidInfoClient, HyperliquidTermsError, PAYMENT_HEADERS, POLYMARKET_CHAIN_ID, POLYMARKET_CLOB_AUTH_DOMAIN, POLYMARKET_CLOB_DOMAIN, POLYMARKET_ENDPOINTS, POLYMARKET_EXCHANGE_ADDRESSES, PolymarketApiError, PolymarketAuthError, PolymarketExchangeClient, PolymarketInfoClient, SUPPORTED_CURRENCIES, StoreError, WEBSEARCH_TOOL_DEFINITION, WEBSEARCH_TOOL_NAME, X402BrowserClient, X402Client, X402PaymentRequiredError, __hyperliquidInternals, __hyperliquidMarketDataInternals, approveHyperliquidBuilderFee, backtestDecisionRequestSchema, batchModifyHyperliquidOrders, buildHmacSignature, buildHyperliquidMarketIdentity, buildHyperliquidProfileAssets, buildHyperliquidSpotUsdPriceMap, buildL1Headers, buildL2Headers, buildPolymarketOrderAmounts, buildSignedOrderPayload, cancelAllHyperliquidOrders, cancelAllPolymarketOrders, cancelHyperliquidOrders, cancelHyperliquidOrdersByCloid, cancelHyperliquidTwapOrder, cancelMarketPolymarketOrders, cancelPolymarketOrder, cancelPolymarketOrders, chains, computeHyperliquidMarketIocLimitPrice, createAIClient, createDevServer, createHyperliquidSubAccount, createMcpAdapter, createMonotonicNonceFactory, createPolymarketApiKey, createStdioServer, defineX402Payment, depositToHyperliquidBridge, derivePolymarketApiKey, ensureTextContent, estimateCountBack, executeTool, extractHyperliquidDex, extractHyperliquidOrderIds, fetchHyperliquidAllMids, fetchHyperliquidAssetCtxs, fetchHyperliquidBars, fetchHyperliquidClearinghouseState, fetchHyperliquidFrontendOpenOrders, fetchHyperliquidHistoricalOrders, fetchHyperliquidMeta, fetchHyperliquidMetaAndAssetCtxs, fetchHyperliquidOpenOrders, fetchHyperliquidOrderStatus, fetchHyperliquidPerpMarketInfo, fetchHyperliquidPreTransferCheck, fetchHyperliquidSizeDecimals, fetchHyperliquidSpotAccountValue, fetchHyperliquidSpotAssetCtxs, fetchHyperliquidSpotClearinghouseState, fetchHyperliquidSpotMarketInfo, fetchHyperliquidSpotMeta, fetchHyperliquidSpotMetaAndAssetCtxs, fetchHyperliquidSpotTickSize, fetchHyperliquidSpotUsdPriceMap, fetchHyperliquidTickSize, fetchHyperliquidUserFills, fetchHyperliquidUserFillsByTime, fetchHyperliquidUserRateLimit, fetchPolymarketMarket, fetchPolymarketMarkets, fetchPolymarketMidpoint, fetchPolymarketOrderbook, fetchPolymarketPrice, fetchPolymarketPriceHistory, flattenMessageContent, formatHyperliquidMarketablePrice, formatHyperliquidOrderSize, formatHyperliquidPrice, formatHyperliquidSize, generateMetadata, generateMetadataCommand, generateText, getHyperliquidMaxBuilderFee, getModelConfig, getMyPerformance, getMyTools, getRpcUrl, getX402PaymentContext, isHyperliquidSpotSymbol, isStreamingSupported, isToolCallingSupported, listModels, loadAndValidateTools, modifyHyperliquidOrder, normalizeHyperliquidBaseSymbol, normalizeHyperliquidMetaSymbol, normalizeModelName, normalizeNumberArrayish, normalizeSpotTokenName2 as normalizeSpotTokenName, normalizeStringArrayish, parseSpotPairSymbol, parseTimeToSeconds, payX402, payX402WithWallet, placeHyperliquidOrder, placeHyperliquidTwapOrder, placePolymarketOrder, postAgentDigest, readHyperliquidAccountValue, readHyperliquidNumber, readHyperliquidPerpPosition, readHyperliquidPerpPositionSize, readHyperliquidSpotAccountValue, readHyperliquidSpotBalance, readHyperliquidSpotBalanceSize, recordHyperliquidBuilderApproval, recordHyperliquidTermsAcceptance, registry, requireX402Payment, reserveHyperliquidRequestWeight, resolutionToSeconds, resolveConfig2 as resolveConfig, resolveExchangeAddress, resolveHyperliquidAbstractionFromMode, resolveHyperliquidChain, resolveHyperliquidChainConfig, resolveHyperliquidErrorDetail, resolveHyperliquidOrderRef, resolveHyperliquidOrderSymbol, resolveHyperliquidPair, resolveHyperliquidProfileChain, resolveHyperliquidRpcEnvVar, resolveHyperliquidStoreNetwork, resolveHyperliquidSymbol, resolvePolymarketBaseUrl, resolveRuntimePath, resolveSpotMidCandidates, resolveSpotTokenCandidates, resolveToolset, responseToToolResponse, retrieve, roundHyperliquidPriceToTick, scheduleHyperliquidCancel, sendHyperliquidSpot, setHyperliquidAccountAbstractionMode, setHyperliquidDexAbstraction, setHyperliquidPortfolioMargin, store, streamText, tokens, transferHyperliquidSubAccount, updateHyperliquidIsolatedMargin, updateHyperliquidLeverage, validateCommand, wallet, walletToolkit, withX402Payment, withdrawFromHyperliquid };
|
|
7397
7525
|
//# sourceMappingURL=index.js.map
|
|
7398
7526
|
//# sourceMappingURL=index.js.map
|