opentool 0.8.27 → 0.8.28

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/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Server } from '@modelcontextprotocol/sdk/server/index.js';
2
- import { I as InternalToolDefinition, T as ToolResponse } from './validate-C4a9tmrQ.js';
3
- export { B as BuildConfig, m as BuildMetadata, p as ConnectedApp, C as CronSpec, r as GetHandler, H as HTTP_METHODS, f as HttpHandlerDefinition, e as HttpMethod, h as McpConfig, M as Metadata, N as NormalizedSchedule, P as PaymentConfig, s as PostHandler, S as ScheduleType, i as ServerConfig, j as Tool, o as ToolAsset, n as ToolCategory, d as ToolContent, k as ToolMetadataOverrides, w as ToolModule, t as ToolModuleGET, u as ToolModulePOST, q as ToolProfile, b as generateMetadata, g as generateMetadataCommand, l as loadAndValidateTools, v as validateCommand } from './validate-C4a9tmrQ.js';
2
+ import { I as InternalToolDefinition, T as ToolResponse } from './validate-3WEA0Ezt.js';
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
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';
package/dist/index.js CHANGED
@@ -6803,6 +6803,11 @@ var SUPPORTED_EXTENSIONS = [
6803
6803
  ".cjs"
6804
6804
  ];
6805
6805
  var MIN_TEMPLATE_CONFIG_VERSION = 2;
6806
+ var TEMPLATE_PREVIEW_TITLE_MAX = 80;
6807
+ var TEMPLATE_PREVIEW_SUBTITLE_MAX = 120;
6808
+ var TEMPLATE_PREVIEW_DESCRIPTION_MAX = 1200;
6809
+ var TEMPLATE_PREVIEW_MIN_LINES = 3;
6810
+ var TEMPLATE_PREVIEW_MAX_LINES = 8;
6806
6811
  function normalizeTemplateConfigVersion(value) {
6807
6812
  if (typeof value === "number" && Number.isFinite(value)) {
6808
6813
  return value;
@@ -6825,6 +6830,67 @@ function normalizeTemplateConfigVersion(value) {
6825
6830
  const major = Number.parseInt(majorMatch[1], 10);
6826
6831
  return Number.isFinite(major) ? major : null;
6827
6832
  }
6833
+ function parseNonEmptyString(value, fieldPath, opts = {}) {
6834
+ const { max, required = false } = opts;
6835
+ if (value == null) {
6836
+ if (required) {
6837
+ throw new Error(`${fieldPath} is required and must be a non-empty string.`);
6838
+ }
6839
+ return null;
6840
+ }
6841
+ if (typeof value !== "string") {
6842
+ throw new Error(`${fieldPath} must be a string.`);
6843
+ }
6844
+ const trimmed = value.trim();
6845
+ if (!trimmed) {
6846
+ throw new Error(`${fieldPath} must be a non-empty string.`);
6847
+ }
6848
+ if (typeof max === "number" && trimmed.length > max) {
6849
+ throw new Error(`${fieldPath} must be <= ${max} characters.`);
6850
+ }
6851
+ return trimmed;
6852
+ }
6853
+ function normalizeTemplatePreview(value, file, toolName, requirePreview) {
6854
+ const pathPrefix = `${file}: profile.templatePreview`;
6855
+ if (value == null) {
6856
+ if (requirePreview) {
6857
+ throw new Error(
6858
+ `${pathPrefix} is required for strategy tools and must define subtitle + description.`
6859
+ );
6860
+ }
6861
+ return null;
6862
+ }
6863
+ if (!value || typeof value !== "object" || Array.isArray(value)) {
6864
+ throw new Error(`${pathPrefix} must be an object.`);
6865
+ }
6866
+ const record = value;
6867
+ const title = parseNonEmptyString(record.title, `${pathPrefix}.title`, {
6868
+ max: TEMPLATE_PREVIEW_TITLE_MAX
6869
+ }) ?? toolName;
6870
+ const subtitle = parseNonEmptyString(record.subtitle, `${pathPrefix}.subtitle`, {
6871
+ required: true,
6872
+ max: TEMPLATE_PREVIEW_SUBTITLE_MAX
6873
+ });
6874
+ const description = parseNonEmptyString(
6875
+ record.description,
6876
+ `${pathPrefix}.description`,
6877
+ {
6878
+ required: true,
6879
+ max: TEMPLATE_PREVIEW_DESCRIPTION_MAX
6880
+ }
6881
+ );
6882
+ const descriptionLineCount = description.split(/\r?\n/).map((line) => line.trim()).filter((line) => line.length > 0).length;
6883
+ if (descriptionLineCount < TEMPLATE_PREVIEW_MIN_LINES || descriptionLineCount > TEMPLATE_PREVIEW_MAX_LINES) {
6884
+ throw new Error(
6885
+ `${pathPrefix}.description must contain ${TEMPLATE_PREVIEW_MIN_LINES}-${TEMPLATE_PREVIEW_MAX_LINES} non-empty lines (target ~5 lines).`
6886
+ );
6887
+ }
6888
+ return {
6889
+ title,
6890
+ subtitle,
6891
+ description
6892
+ };
6893
+ }
6828
6894
  async function validateCommand(options) {
6829
6895
  console.log("\u{1F50D} Validating OpenTool metadata...");
6830
6896
  try {
@@ -6902,16 +6968,26 @@ async function loadAndValidateTools(toolsDir, options = {}) {
6902
6968
  throw new Error(`${file}: export exactly one of GET or POST`);
6903
6969
  }
6904
6970
  let normalizedSchedule = null;
6905
- const schedule = toolModule?.profile?.schedule;
6906
- const profileNotifyEmail = typeof toolModule?.profile?.notifyEmail === "boolean" ? toolModule.profile.notifyEmail : void 0;
6907
- const profileCategoryRaw = typeof toolModule?.profile?.category === "string" ? toolModule.profile.category : void 0;
6908
- const allowedProfileCategories = /* @__PURE__ */ new Set(["strategy", "tracker", "orchestrator"]);
6909
- if (profileCategoryRaw && !allowedProfileCategories.has(profileCategoryRaw)) {
6910
- throw new Error(
6911
- `${file}: profile.category must be one of ${Array.from(allowedProfileCategories).join(", ")}`
6912
- );
6971
+ const profileRaw = toolModule?.profile && typeof toolModule.profile === "object" ? toolModule.profile : null;
6972
+ const schedule = profileRaw?.schedule ?? null;
6973
+ const profileNotifyEmail = typeof profileRaw?.notifyEmail === "boolean" ? profileRaw.notifyEmail : void 0;
6974
+ const allowedProfileCategories = [
6975
+ "strategy",
6976
+ "tracker",
6977
+ "orchestrator"
6978
+ ];
6979
+ const profileCategoryCandidate = typeof profileRaw?.category === "string" ? profileRaw.category : void 0;
6980
+ let profileCategoryRaw;
6981
+ if (profileCategoryCandidate !== void 0) {
6982
+ const isAllowed = allowedProfileCategories.includes(profileCategoryCandidate);
6983
+ if (!isAllowed) {
6984
+ throw new Error(
6985
+ `${file}: profile.category must be one of ${allowedProfileCategories.join(", ")}`
6986
+ );
6987
+ }
6988
+ profileCategoryRaw = profileCategoryCandidate;
6913
6989
  }
6914
- const profileAssetsRaw = toolModule?.profile?.assets;
6990
+ const profileAssetsRaw = profileRaw?.assets;
6915
6991
  if (profileAssetsRaw !== void 0) {
6916
6992
  if (!Array.isArray(profileAssetsRaw)) {
6917
6993
  throw new Error(`${file}: profile.assets must be an array.`);
@@ -6969,7 +7045,7 @@ async function loadAndValidateTools(toolsDir, options = {}) {
6969
7045
  }
6970
7046
  });
6971
7047
  }
6972
- const templateConfigRaw = toolModule?.profile?.templateConfig;
7048
+ const templateConfigRaw = profileRaw?.templateConfig;
6973
7049
  if (templateConfigRaw !== void 0) {
6974
7050
  if (!templateConfigRaw || typeof templateConfigRaw !== "object") {
6975
7051
  throw new Error(`${file}: profile.templateConfig must be an object.`);
@@ -7006,6 +7082,13 @@ async function loadAndValidateTools(toolsDir, options = {}) {
7006
7082
  );
7007
7083
  }
7008
7084
  }
7085
+ const normalizedTemplatePreview = normalizeTemplatePreview(
7086
+ profileRaw?.templatePreview,
7087
+ file,
7088
+ toolName,
7089
+ profileCategoryRaw === "strategy"
7090
+ );
7091
+ const normalizedProfile = profileRaw && normalizedTemplatePreview ? { ...profileRaw, templatePreview: normalizedTemplatePreview } : profileRaw;
7009
7092
  if (hasGET && schedule && typeof schedule.cron === "string" && schedule.cron.trim().length > 0) {
7010
7093
  normalizedSchedule = normalizeScheduleExpression(schedule.cron, file);
7011
7094
  if (typeof schedule.enabled === "boolean") {
@@ -7075,9 +7158,9 @@ async function loadAndValidateTools(toolsDir, options = {}) {
7075
7158
  handler: async (params) => adapter(params),
7076
7159
  payment: paymentExport ?? null,
7077
7160
  schedule: normalizedSchedule,
7078
- profile: toolModule?.profile && typeof toolModule.profile === "object" ? toolModule.profile : null,
7161
+ profile: normalizedProfile,
7079
7162
  ...profileNotifyEmail !== void 0 ? { notifyEmail: profileNotifyEmail } : {},
7080
- profileDescription: typeof toolModule?.profile?.description === "string" ? toolModule.profile?.description ?? null : null,
7163
+ profileDescription: typeof profileRaw?.description === "string" ? profileRaw.description : null,
7081
7164
  ...profileCategoryRaw ? { profileCategory: profileCategoryRaw } : {}
7082
7165
  };
7083
7166
  tools.push(tool);