import { McpToolResult, Subscription, McpResourceContent, CvmRegistryQuery, CvmRegistryEntry, CvmRegistryOptions, JsonObject, CvmRegistryCallOptions } from '@napplet/core'; import { c as CvmServerRef, a as CvmRequestOptions, C as CvmDiscoverQuery, b as CvmServer, e as McpResource, f as McpTool, d as McpMessage } from '../cvm-server-types-CMD9X8bD.js'; /** * Handle cvm.* messages from the shell via the central message listener. * Covers cvm.discover.result, cvm.request.result, cvm.close.result, and cvm.event. */ declare function handleCvmMessage(msg: { type: string; [key: string]: unknown; }): void; /** * Discover public ContextVM servers known to the shell. * * @param query Optional discovery filter (`search`, `kinds`, `relays`, `limit`) * @returns Promise resolving to the discovered servers * * @example * ```ts * const servers = await discover({ search: 'relay', limit: 5 }); * ``` */ declare function discover(query?: CvmDiscoverQuery): Promise; /** * Send a raw MCP JSON-RPC message to a ContextVM server and resolve with the * matching MCP response. The shell handles ContextVM transport, correlation, * signature verification, and (per options) initialization and payment. * * @param server Target ContextVM server (pubkey + optional relay hints) * @param message MCP JSON-RPC message to deliver * @param options Optional per-request options (`timeoutMs`, `initialize`, `payment`) * @returns Promise resolving to the MCP response message * * @example * ```ts * const reply = await request( * { pubkey: '65a334...' }, * { jsonrpc: '2.0', id: 1, method: 'tools/list' }, * { initialize: true }, * ); * ``` */ declare function request(server: CvmServerRef, message: McpMessage, options?: CvmRequestOptions): Promise; /** * List the tools exposed by a ContextVM server (MCP `tools/list`). * * @param server Target ContextVM server * @param options Optional per-request options * @returns Promise resolving to the server's tool definitions */ declare function listTools(server: CvmServerRef, options?: CvmRequestOptions): Promise; /** * Call a tool on a ContextVM server (MCP `tools/call`). * * @param server Target ContextVM server * @param name Tool name (from {@link listTools}) * @param args Tool arguments * @param options Optional per-request options * @returns Promise resolving to the MCP tool result * * @example * ```ts * const result = await callTool( * { pubkey: '65a334...' }, * 'get_relay', * { url: 'wss://relay.example.com' }, * { payment: 'prompt' }, * ); * ``` */ declare function callTool(server: CvmServerRef, name: string, args?: Record, options?: CvmRequestOptions): Promise; /** * List the resources exposed by a ContextVM server (MCP `resources/list`). * * @param server Target ContextVM server * @param options Optional per-request options * @returns Promise resolving to the server's resource descriptors */ declare function listResources(server: CvmServerRef, options?: CvmRequestOptions): Promise; /** * Read a resource from a ContextVM server (MCP `resources/read`). * * MCP returns a `contents` array; this convenience wrapper resolves with the * first entry per the NAP-CVM API surface. Use {@link request} directly for * multi-content resources. * * @param server Target ContextVM server * @param uri Resource URI (from {@link listResources}) * @param options Optional per-request options * @returns Promise resolving to the first resource content entry (text or blob) */ declare function readResource(server: CvmServerRef, uri: string, options?: CvmRequestOptions): Promise; /** * Close shell-maintained session state for a server (subscriptions, cached * initialization state, pending correlation records). * * @param server Server whose session should be torn down * @returns Promise that resolves once the shell confirms closure */ declare function close(server: CvmServerRef): Promise; /** * Listen for server-pushed MCP messages (`cvm.event`) -- notifications and * unsolicited server messages not correlated to a single request. The callback * receives every event; filter on `server.pubkey` when scoping to one server. * * @param callback Called with `(server, message)` for each server event * @returns A Subscription with `close()` to stop listening * * @example * ```ts * const sub = onEvent((server, message) => { * if (message.method === 'notifications/progress') updateProgress(message.params); * }); * // later: sub.close(); * ``` */ declare function onEvent(callback: (server: CvmServerRef, message: McpMessage) => void): Subscription; /** * List shell-curated ContextVM registry families. * * @param query Optional search/family/schema filter * @returns Promise resolving to registry entries */ declare function registryList(query?: CvmRegistryQuery): Promise; /** * Test whether the shell can call a ContextVM registry family. * * @param family Registry family name * @param options Optional schema/provider constraints * @returns Promise resolving to availability */ declare function registryHas(family: string, options?: CvmRegistryOptions): Promise; /** * Describe a shell-selected ContextVM registry family. * * @param family Registry family name * @param options Optional schema/provider constraints * @returns Promise resolving to the selected registry entry */ declare function registryDescribe(family: string, options?: CvmRegistryOptions): Promise; /** * Call a tool on the shell-selected provider for a ContextVM registry family. * * @param family Registry family name * @param tool Tool name inside the family * @param args Optional tool arguments * @param options Optional schema/provider/cache/payment constraints * @returns Promise resolving to the MCP tool result */ declare function registryCall(family: string, tool: string, args?: JsonObject, options?: CvmRegistryCallOptions): Promise; /** Shell-curated ContextVM registry helper namespace. */ declare const registry: { list: typeof registryList; has: typeof registryHas; describe: typeof registryDescribe; call: typeof registryCall; }; /** * Napplet NAP cvm shim entrypoint. * * @module */ /** Install the ContextVM shim and return its cleanup function. */ declare function installCvmShim(): () => void; export { callTool, close, discover, handleCvmMessage, installCvmShim, listResources, listTools, onEvent, readResource, registry, registryCall, registryDescribe, registryHas, registryList, request };