opentool 0.7.10 → 0.7.11
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 +1 -0
- package/dist/index.js +68 -1
- package/dist/index.js.map +1 -1
- package/dist/store/index.d.ts +41 -0
- package/dist/store/index.js +70 -0
- package/dist/store/index.js.map +1 -0
- package/package.json +5 -1
package/dist/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ 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';
|
|
7
7
|
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';
|
|
8
|
+
export { StoreAction, StoreError, StoreEventInput, StoreOptions, StoreResponse, store } from './store/index.js';
|
|
8
9
|
import 'viem';
|
|
9
10
|
import 'viem/accounts';
|
|
10
11
|
|
package/dist/index.js
CHANGED
|
@@ -2274,6 +2274,73 @@ function toAbortError(reason) {
|
|
|
2274
2274
|
}
|
|
2275
2275
|
return new AIAbortError(String(reason ?? "AI request aborted"));
|
|
2276
2276
|
}
|
|
2277
|
+
|
|
2278
|
+
// src/store/index.ts
|
|
2279
|
+
var StoreError = class extends Error {
|
|
2280
|
+
constructor(message, status, causeData) {
|
|
2281
|
+
super(message);
|
|
2282
|
+
this.status = status;
|
|
2283
|
+
this.causeData = causeData;
|
|
2284
|
+
this.name = "StoreError";
|
|
2285
|
+
}
|
|
2286
|
+
};
|
|
2287
|
+
function resolveConfig2(options) {
|
|
2288
|
+
const baseUrl = options?.baseUrl ?? process.env.BASE_URL;
|
|
2289
|
+
const apiKey = options?.apiKey ?? process.env.OPENPOND_API_KEY;
|
|
2290
|
+
if (!baseUrl) {
|
|
2291
|
+
throw new StoreError("BASE_URL is required to store activity events");
|
|
2292
|
+
}
|
|
2293
|
+
if (!apiKey) {
|
|
2294
|
+
throw new StoreError(
|
|
2295
|
+
"OPENPOND_API_KEY is required to store activity events"
|
|
2296
|
+
);
|
|
2297
|
+
}
|
|
2298
|
+
const normalizedBaseUrl = baseUrl.replace(/\/$/, "");
|
|
2299
|
+
const fetchFn = options?.fetchFn ?? globalThis.fetch;
|
|
2300
|
+
if (!fetchFn) {
|
|
2301
|
+
throw new StoreError("Fetch is not available in this environment");
|
|
2302
|
+
}
|
|
2303
|
+
return { baseUrl: normalizedBaseUrl, apiKey, fetchFn };
|
|
2304
|
+
}
|
|
2305
|
+
async function store(input, options) {
|
|
2306
|
+
const { baseUrl, apiKey, fetchFn } = resolveConfig2(options);
|
|
2307
|
+
const url = `${baseUrl}/apps/positions/tx`;
|
|
2308
|
+
let response;
|
|
2309
|
+
try {
|
|
2310
|
+
response = await fetchFn(url, {
|
|
2311
|
+
method: "POST",
|
|
2312
|
+
headers: {
|
|
2313
|
+
"content-type": "application/json",
|
|
2314
|
+
"openpond-api-key": apiKey
|
|
2315
|
+
},
|
|
2316
|
+
body: JSON.stringify(input)
|
|
2317
|
+
});
|
|
2318
|
+
} catch (error) {
|
|
2319
|
+
throw new StoreError("Failed to reach store endpoint", void 0, error);
|
|
2320
|
+
}
|
|
2321
|
+
if (!response.ok) {
|
|
2322
|
+
let body;
|
|
2323
|
+
try {
|
|
2324
|
+
body = await response.json();
|
|
2325
|
+
} catch {
|
|
2326
|
+
body = await response.text().catch(() => void 0);
|
|
2327
|
+
}
|
|
2328
|
+
throw new StoreError(
|
|
2329
|
+
`Store request failed with status ${response.status}`,
|
|
2330
|
+
response.status,
|
|
2331
|
+
body
|
|
2332
|
+
);
|
|
2333
|
+
}
|
|
2334
|
+
try {
|
|
2335
|
+
const data = await response.json();
|
|
2336
|
+
return {
|
|
2337
|
+
id: data.id ?? "",
|
|
2338
|
+
status: data.status ?? null
|
|
2339
|
+
};
|
|
2340
|
+
} catch {
|
|
2341
|
+
return { id: "", status: null };
|
|
2342
|
+
}
|
|
2343
|
+
}
|
|
2277
2344
|
var METADATA_SPEC_VERSION = "1.1.0";
|
|
2278
2345
|
var McpAnnotationsSchema = z.object({
|
|
2279
2346
|
title: z.string().optional(),
|
|
@@ -3116,6 +3183,6 @@ function timestamp() {
|
|
|
3116
3183
|
return (/* @__PURE__ */ new Date()).toISOString().replace("T", " ").slice(0, 19);
|
|
3117
3184
|
}
|
|
3118
3185
|
|
|
3119
|
-
export { AIAbortError, AIError, AIFetchError, AIResponseError, DEFAULT_BASE_URL, DEFAULT_CHAIN, DEFAULT_FACILITATOR, DEFAULT_MODEL, DEFAULT_TIMEOUT_MS, DEFAULT_TOKENS, HTTP_METHODS2 as HTTP_METHODS, PAYMENT_HEADERS, SUPPORTED_CURRENCIES, WEBSEARCH_TOOL_DEFINITION, WEBSEARCH_TOOL_NAME, X402BrowserClient, X402Client, X402PaymentRequiredError, chains, createAIClient, createDevServer, createMcpAdapter, createStdioServer, defineX402Payment, ensureTextContent, flattenMessageContent, generateMetadata, generateMetadataCommand, generateText, getModelConfig, getRpcUrl, getX402PaymentContext, isStreamingSupported, isToolCallingSupported, listModels, loadAndValidateTools, normalizeModelName, payX402, payX402WithWallet, registry, requireX402Payment, resolveConfig, resolveRuntimePath, resolveToolset, responseToToolResponse, streamText, tokens, validateCommand, wallet, walletToolkit, withX402Payment };
|
|
3186
|
+
export { AIAbortError, AIError, AIFetchError, AIResponseError, DEFAULT_BASE_URL, DEFAULT_CHAIN, DEFAULT_FACILITATOR, DEFAULT_MODEL, DEFAULT_TIMEOUT_MS, DEFAULT_TOKENS, HTTP_METHODS2 as HTTP_METHODS, PAYMENT_HEADERS, SUPPORTED_CURRENCIES, StoreError, WEBSEARCH_TOOL_DEFINITION, WEBSEARCH_TOOL_NAME, X402BrowserClient, X402Client, X402PaymentRequiredError, chains, createAIClient, createDevServer, createMcpAdapter, createStdioServer, defineX402Payment, ensureTextContent, flattenMessageContent, generateMetadata, generateMetadataCommand, generateText, getModelConfig, getRpcUrl, getX402PaymentContext, isStreamingSupported, isToolCallingSupported, listModels, loadAndValidateTools, normalizeModelName, payX402, payX402WithWallet, registry, requireX402Payment, resolveConfig, resolveRuntimePath, resolveToolset, responseToToolResponse, store, streamText, tokens, validateCommand, wallet, walletToolkit, withX402Payment };
|
|
3120
3187
|
//# sourceMappingURL=index.js.map
|
|
3121
3188
|
//# sourceMappingURL=index.js.map
|