import type { Tool } from "@modelcontextprotocol/server"; import type { ToolContext, ToolResult } from '../types.js'; import type { RiskLevel } from '../core/tool-registry.js'; import { BRIDGE_PORT, BRIDGE_HOST, BRIDGE_SCRIPT_NAME, AUTOLOAD_KEY, ERROR_CODES, BridgeNotConnectedError, BridgeTimeoutError, clampTimeoutMs, resolveBridgePort, bridgeSecretPathFor, getBridgeProjectDir, invalidateBridgeSecret, invalidateBridgeConnection, registerBridgePushHandler, type BridgeResponse, setBridgeProjectDir, sendToBridge } from '../core/bridge-client.js'; export { BRIDGE_PORT, BRIDGE_HOST, BRIDGE_SCRIPT_NAME, AUTOLOAD_KEY, ERROR_CODES, BridgeNotConnectedError, BridgeTimeoutError, clampTimeoutMs, resolveBridgePort, bridgeSecretPathFor, getBridgeProjectDir, invalidateBridgeSecret, invalidateBridgeConnection, registerBridgePushHandler, setBridgeProjectDir, sendToBridge, type BridgeResponse, }; export { machineRegistryInstancesDir, normalizeProjectKey, setOnBridgeConnected } from '../core/bridge-client.js'; export interface SyncCompareReport { in_sync: boolean; paths_compared: number; missing_in_b: string[]; missing_in_a: string[]; diffs: Array<{ path: string; key: string; a: unknown; b: unknown; }>; } /** * 递归比对两份 collect_state 快照(浮点容差)。 * 数值 |a-b|<=tolerance 视为相等(浮点位置类不逐位相等是多人比对必然——host/client * 各自物理步进后 position 必有微差,masteryee 原版 dict 严格相等在真实多人游戏永远 * false,亲读发现的坑,本函数是该坑的修复);其余类型严格相等;dict 逐键/数组逐项+长度。 */ export declare function compareStates(a: Record, b: Record, tolerance: number): SyncCompareReport; export declare function getToolDefinitions(): Tool[]; export declare const QUERY_METHODS: Set; /** Read-only query methods excluding take_screenshot (handled separately via bridge.screenshot). */ export declare const BRIDGE_READ_ONLY_METHODS: Set; export declare const INPUT_METHODS: Set; export declare const PLAYTEST_METHODS: Set; export declare const CONTROL_METHODS: Set; /** * G-3 (:942② + 批D移交): 计算 game_playtest 各 method 的 TS 侧请求 timeout(纯函数,无 IO)。 * * step_until 的竞态根因: 原 `min(max(raw,30000),60000)` 与 GD 侧 idle 60s(mcp_bridge.gd * INACTIVITY_TIMEOUT)同界 — wall_budget_ms=60000 时 TS 先到期销毁常驻 socket(响应丢失 + * 订阅断线)。批 D 已把 GD 侧 wall_budget clamp 到 50s,TS 侧对齐: * `wall_budget + 5s 余量`(默认 30000 → 35000;wall=60000 超界入参 → 65000 不再先到期), * 并与用户显式 timeout 取 max(用户显式更长时尊重显式意图,不被 wall 公式压短)。 * * 其余 method 保持原行为: step 走 max(raw,30000) cap 60000;非长跑 method 原样。 */ export declare function computePlaytestTimeoutMs(method: string, wallBudgetMs: unknown, rawTimeoutMs: number): number; /** * CRITICAL-3 fix: poll a Bridge wait condition until it holds or the budget * runs out. Bridge (`mcp_bridge.gd` `_cmd_wait_for_node`/`_cmd_wait_for_property`) * is a single synchronous snapshot, so "waiting" must be implemented by the * caller polling within a time window. * * `probe` is parameterized so tests can inject a mock without touching the * real socket. Each probe call should return the BridgeResponse from a single * `wait_for_node`/`wait_for_property` snapshot. * * Condition resolution: * - `wait_for_node` → holds when result.exists === true * - `wait_for_property` → holds when result.match === true * - any result.error → abort immediately, surface the error * * The returned object spreads the last Bridge result and augments it with * `wait_completed` / `elapsed_ms` / `timed_out`, so existing fields stay * backward compatible. */ export declare function pollWaitCondition(method: 'wait_for_node' | 'wait_for_property', probe: () => Promise, totalMs: number, intervalMs: number, sleep?: (ms: number) => Promise): Promise>; /** T-1 (2026-06-24 审查): game_write/wait/query 的 path 参数须 /root/ 绝对路径(文档 godot-mcp-bridge.md * 声称必须,原 TS 端下放 GDScript 端)。无 path 的 method(ping/get_tree/get_performance 等)不校验。 * 返回错误消息或 null(校验通过)。纯函数,无 IO/socket,测试见 game-bridge-validation.test.ts。 * 反馈 2026-08-22 (CardGame2): take_screenshot 的 path 是文件路径语义(user://…,GD 侧自有 * "must start with user://" 校验),曾被本函数误扫为节点路径——两层校验互相矛盾,任意取值必失败。 * 修:method 为 take_screenshot 时跳过 path 键(其 path 非节点路径);node_path 键仍校验(该方法无此参数)。 */ export declare function validateBridgePath(params: Record, method?: string): string | null; /** I-2 (审查 follow-up): wait_for_property 需 property + value;wait_for_node 只需 path 不校验。 * 返回错误消息或 null(校验通过)。纯函数,无 IO/socket,测试见 game-bridge-validation.test.ts。 * 抽自 handleTool case 'game_wait' 内联逻辑(2026-08-09 待办 #3,恢复 Linux CI 覆盖)。 */ export declare function validateWaitPropertyParams(method: string, params: Record): string | null; export declare function handleTool(name: string, args: Record, ctx: ToolContext): Promise; export declare const TOOL_META: Record; }>; export { resetBridgeState, isBridgeReady, _testBridgeCacheState, type BridgeReadyResult } from '../core/bridge-client.js';