opentool 0.7.9 → 0.7.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.
- package/README.md +6 -1
- package/dist/cli/index.d.ts +3 -2
- package/dist/cli/index.js +101 -2
- package/dist/cli/index.js.map +1 -1
- package/dist/index.d.ts +5 -2
- package/dist/index.js +44 -1
- package/dist/index.js.map +1 -1
- package/dist/{validate-BBjyq5nS.d.ts → validate-uetwG5jo.d.ts} +9 -1
- package/package.json +1 -1
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-
|
|
3
|
-
export { B as BuildConfig,
|
|
2
|
+
import { I as InternalToolDefinition, T as ToolResponse } from './validate-uetwG5jo.js';
|
|
3
|
+
export { B as BuildConfig, m as BuildMetadata, H as HTTP_METHODS, f as HttpHandlerDefinition, e as HttpMethod, h as McpConfig, M as Metadata, N as NormalizedSchedule, P as PaymentConfig, S as ScheduleType, i as ServerConfig, j as Tool, d as ToolContent, k as ToolMetadataOverrides, b as generateMetadata, g as generateMetadataCommand, l as loadAndValidateTools, v as validateCommand } from './validate-uetwG5jo.js';
|
|
4
4
|
import { z, ZodSchema } from 'zod';
|
|
5
5
|
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';
|
|
6
6
|
export { ChainMetadata, ChainReference, ChainTokenMap, DEFAULT_CHAIN, DEFAULT_TOKENS, Hex, HexAddress, RpcProviderOptions, RpcUrlResolver, TokenMetadata, TurnkeyOptions, TurnkeySignWith, WalletBaseContext, WalletContext, WalletFullContext, WalletOptions, WalletOptionsBase, WalletPrivateKeyOptions, WalletProviderType, WalletReadonlyContext, WalletReadonlyOptions, WalletRegistry, WalletSendTransactionParams, WalletSignerContext, WalletTransferParams, WalletTurnkeyOptions, chains, getRpcUrl, registry, tokens, wallet, walletToolkit } from './wallets/index.js';
|
|
@@ -19,6 +19,9 @@ declare function createStdioServer(tools?: InternalToolDefinition[]): Promise<vo
|
|
|
19
19
|
declare function resolveRuntimePath(value: string): string;
|
|
20
20
|
|
|
21
21
|
type CronSpec = {
|
|
22
|
+
/**
|
|
23
|
+
* AWS EventBridge schedule expression (`cron(...)` or `rate(...)`).
|
|
24
|
+
*/
|
|
22
25
|
cron: string;
|
|
23
26
|
enabled?: boolean;
|
|
24
27
|
};
|
package/dist/index.js
CHANGED
|
@@ -2696,6 +2696,42 @@ function buildDiscovery(authored) {
|
|
|
2696
2696
|
};
|
|
2697
2697
|
return Object.keys(merged).length > 0 ? merged : void 0;
|
|
2698
2698
|
}
|
|
2699
|
+
|
|
2700
|
+
// src/utils/schedule.ts
|
|
2701
|
+
var CRON_WRAPPED_REGEX = /^cron\((.*)\)$/i;
|
|
2702
|
+
var CRON_TOKEN_REGEX = /^[A-Za-z0-9*?/,\-#L]+$/;
|
|
2703
|
+
function normalizeScheduleExpression(raw, context) {
|
|
2704
|
+
const value = raw?.trim();
|
|
2705
|
+
if (!value) {
|
|
2706
|
+
throw new Error(`${context}: profile.schedule.cron must be a non-empty string`);
|
|
2707
|
+
}
|
|
2708
|
+
const cronBody = extractCronBody(value);
|
|
2709
|
+
const cronFields = cronBody.trim().split(/\s+/).filter(Boolean);
|
|
2710
|
+
if (cronFields.length !== 5 && cronFields.length !== 6) {
|
|
2711
|
+
throw new Error(`${context}: cron expression must have 5 or 6 fields (got ${cronFields.length})`);
|
|
2712
|
+
}
|
|
2713
|
+
validateCronTokens(cronFields, context);
|
|
2714
|
+
return {
|
|
2715
|
+
type: "cron",
|
|
2716
|
+
expression: cronFields.join(" ")
|
|
2717
|
+
};
|
|
2718
|
+
}
|
|
2719
|
+
function extractCronBody(value) {
|
|
2720
|
+
const cronMatch = CRON_WRAPPED_REGEX.exec(value);
|
|
2721
|
+
if (cronMatch) {
|
|
2722
|
+
return (cronMatch[1] ?? "").trim();
|
|
2723
|
+
}
|
|
2724
|
+
return value;
|
|
2725
|
+
}
|
|
2726
|
+
function validateCronTokens(fields, context) {
|
|
2727
|
+
fields.forEach((token2, idx) => {
|
|
2728
|
+
if (!CRON_TOKEN_REGEX.test(token2)) {
|
|
2729
|
+
throw new Error(`${context}: invalid cron token "${token2}" at position ${idx + 1}`);
|
|
2730
|
+
}
|
|
2731
|
+
});
|
|
2732
|
+
}
|
|
2733
|
+
|
|
2734
|
+
// src/cli/validate.ts
|
|
2699
2735
|
var SUPPORTED_EXTENSIONS = [
|
|
2700
2736
|
".ts",
|
|
2701
2737
|
".tsx",
|
|
@@ -2780,11 +2816,16 @@ async function loadAndValidateTools(toolsDir, options = {}) {
|
|
|
2780
2816
|
if (hasGET === hasPOST) {
|
|
2781
2817
|
throw new Error(`${file}: export exactly one of GET or POST`);
|
|
2782
2818
|
}
|
|
2819
|
+
let normalizedSchedule = null;
|
|
2783
2820
|
if (hasGET) {
|
|
2784
2821
|
const schedule = toolModule?.profile?.schedule;
|
|
2785
2822
|
if (!schedule || typeof schedule?.cron !== "string" || schedule.cron.trim().length === 0) {
|
|
2786
2823
|
throw new Error(`${file}: GET tools require profile.schedule { cron }`);
|
|
2787
2824
|
}
|
|
2825
|
+
normalizedSchedule = normalizeScheduleExpression(schedule.cron, file);
|
|
2826
|
+
if (typeof schedule.enabled === "boolean") {
|
|
2827
|
+
normalizedSchedule.authoredEnabled = schedule.enabled;
|
|
2828
|
+
}
|
|
2788
2829
|
}
|
|
2789
2830
|
if (hasPOST) {
|
|
2790
2831
|
if (!schema) {
|
|
@@ -2841,7 +2882,9 @@ async function loadAndValidateTools(toolsDir, options = {}) {
|
|
|
2841
2882
|
filename: toBaseName(file),
|
|
2842
2883
|
sourcePath: path5.join(toolsDir, file),
|
|
2843
2884
|
handler: async (params) => adapter(params),
|
|
2844
|
-
payment: paymentExport ?? null
|
|
2885
|
+
payment: paymentExport ?? null,
|
|
2886
|
+
schedule: normalizedSchedule,
|
|
2887
|
+
profileDescription: typeof toolModule?.profile?.description === "string" ? toolModule.profile?.description ?? null : null
|
|
2845
2888
|
};
|
|
2846
2889
|
tools.push(tool);
|
|
2847
2890
|
}
|