/** * Native Vector Search Skill - Document search over a local or remote index. * * Port of the Python `NativeVectorSearchSkill`. Supports three backends in * Python (SQLite `.swsearch`, PostgreSQL `pgvector`, and a remote HTTP * search server). This TypeScript implementation provides: * * - In-memory TF-IDF search over `documents` passed via config (fast path * that needs no additional deps), and * - Remote HTTP search via a configured `remote_url` (compatible with the * Python SDK's `sw-search` remote protocol). * * The SQLite/pgvector backends require native Python dependencies and are * not available here; their schema entries are preserved so configuration * written for the Python SDK remains valid. */ import { SkillBase } from '../SkillBase.js'; import type { SkillToolDefinition, SkillPromptSection, SkillConfig, ParameterSchemaEntry } from '../SkillBase.js'; import type { AgentBase } from '../../AgentBase.js'; /** * Callback signature for customizing the formatted search response. * * The context object is the TypeScript idiom for Python's positional-args * convention: `(response, agent, query, results, args)`. All Python fields are * present plus TS-specific additions (`count`, `skill`): * * - `response` — pre-formatted response string (same as Python arg 1) * - `agent` — the AgentBase instance that owns this skill (same as Python arg 2) * - `query` — the search query string (same as Python arg 3) * - `results` — array of search results (same as Python arg 4) * - `args` — raw tool call arguments (same as Python arg 5) * - `count` — requested result count (TS addition) * - `skill` — this skill instance (TS addition) */ export type ResponseFormatCallback = (ctx: { response: string; /** The AgentBase instance that owns this skill. Equivalent to Python's `agent` positional arg. */ agent?: AgentBase; query: string; results: Array<{ content: string; score: number; metadata: Record; }>; args: Record; count: number; skill: NativeVectorSearchSkill; }) => string; /** * Document search using TF-IDF in-memory scoring or a remote search server. * * Multi-instance capable (distinguished by `tool_name` + `index_file`). * * @example Local JSON index * ```ts * agent.addSkill('native_vector_search', { * tool_name: 'search_docs', * index_file: './data/support-docs.json', * count: 3, * }); * ``` */ export declare class NativeVectorSearchSkill extends SkillBase { static SKILL_NAME: string; static SKILL_DESCRIPTION: string; static SKILL_VERSION: string; static REQUIRED_PACKAGES: readonly string[]; static REQUIRED_ENV_VARS: readonly string[]; static SUPPORTS_MULTIPLE_INSTANCES: boolean; static getParameterSchema(): Record; private toolName; private backend; private indexFile; private remoteUrl; private indexName; private count; private similarityThreshold; private filterTags; private noResultsMessage; private responsePrefix; private responsePostfix; private maxContentLength; private responseFormatCallback; private description; private verbose; /** * Hybrid scoring weight: 0.0 = pure TF-IDF, 1.0 = pure keyword overlap. * `null` means "use Python default of 0.3 at search time" — matches * Python `SearchEngine._merge_all_results` behavior when `keyword_weight` * is None (see `search_engine.py` line 449). */ private keywordWeight; private searchAvailable; private useRemote; private remoteBaseUrl; private remoteAuth; private _documents; private _tokenizedDocs; private _docTfs; private _idf; private _indexed; getInstanceKey(): string; setup(): Promise; getHints(): string[]; getGlobalData(): Record; cleanup(): Promise; /** * Load and TF-IDF-index documents from config. * Applies `global_tags` to every document's tag list. */ private _loadDocuments; /** @returns A single search tool using the configured `tool_name` (default `search_knowledge`). */ getTools(): SkillToolDefinition[]; /** @returns Prompt section describing the local document search capabilities. */ protected _getPromptSections(): SkillPromptSection[]; private _searchHandler; private _searchLocal; /** Perform search against a remote search server. */ private _searchRemote; /** Fetch wrapper that injects Basic auth if configured. */ private _fetchWithAuth; } /** * Factory function for creating NativeVectorSearchSkill instances. * @param config - Optional skill configuration. * @returns A new NativeVectorSearchSkill instance. */ export declare function createSkill(config?: SkillConfig): NativeVectorSearchSkill;