/** * argsMapper —— MCP 工具入参映射。 * * 根据 {@link ArgsMappingRule} 在**调用代码层**(调 client.callTool 前)对工具参数做: * - **CONST**:强制该参数为固定值(覆盖 agent 传入) * - **DEFAULT**:agent 自行决定;若 agent 未传该参数,用 rule.value 作默认值 * - **disabled**:屏蔽该参数(删除,即使 agent 传了也删) * * `argJsonPath` 用 jsonpath 风格语法(点分 `a.b` + 数组下标 `a[0]`,如 `a.b[0].c`)。 * 规则按 `mcpToolName` 匹配工具后生效;多条规则按数组顺序执行(后覆盖前)。 * * 说明:曾评估用 `jsonpath-plus` 包,但其仅提供 query(取值),无 set/delete/建路径 API, * 无法满足 CONST/DEFAULT 建值 + disabled 删除语义。故自写最小 get/set/unset(零新依赖)。 */ import { type ArgsMappingRule } from '../../../vendor/linkque-agent-protocol/index.js'; /** path segment:字符串为对象键,数字为数组下标。 */ type Segment = string | number; /** * 解析 JSON path 为 segments:`a.b[0].c` → `['a','b',0,'c']`。 * 数字段转下标;非法格式(如空括号)按字面量 key 处理(容错,不抛错)。 */ export declare function parsePath(path: string): Segment[]; /** 沿 segments 取值;路径不存在返回 undefined。 */ export declare function getByPath(obj: Record | undefined, segments: Segment[]): unknown; /** * 沿 segments 设值;按需创建中间对象(字符串 seg → 对象,数字 seg → 数组)。 * 修改 obj 原地(已 clone,调用方安全)。 */ export declare function setByPath(obj: Record, segments: Segment[], value: unknown): void; /** 沿 segments 删除末端值;中间节点删空不回收(保持简单)。 */ export declare function unsetByPath(obj: Record, segments: Segment[]): void; /** * 对给定工具的 args 应用映射规则,返回处理后的 args。 * * @param toolName 目标工具名(规则按 mcpToolName 匹配) * @param args agent 传入的原始参数(可为 undefined) * @param rules 该 MCP 资源的规则全集(仅 mcpToolName===toolName 的生效) * @returns 处理后的 args(可能是空对象) */ export declare function applyArgsMappingRules(toolName: string, args: Record | undefined, rules: ArgsMappingRule[] | undefined): Record; export {};