export function registerWbState(server, client) {
    server.registerTool("wb_state", {
        description: "Get a full snapshot of the current Workbench state. Returns mode (edit/play), entity count, selected entity count and names, terrain bounds, sub-scene, and prefab edit status.",
        inputSchema: {},
    }, async () => {
        try {
            const result = await client.call("EMCP_WB_GetState");
            const lines = ["**Workbench State**\n"];
            if (result.mode)
                lines.push(`- **Mode:** ${result.mode}`);
            if (result.entityCount !== undefined)
                lines.push(`- **Entity Count:** ${result.entityCount}`);
            if (result.selectedCount !== undefined)
                lines.push(`- **Selected:** ${result.selectedCount}`);
            // Selected entity names (handler packs as selectedNames array)
            if (Array.isArray(result.selectedNames) && result.selectedNames.length > 0) {
                const names = result.selectedNames.filter((n) => typeof n === "string" && n.length > 0);
                if (names.length > 0) {
                    lines.push(`- **Selected Entities:** ${names.join(", ")}`);
                }
            }
            if (result.currentSubScene !== undefined)
                lines.push(`- **Sub-Scene:** ${result.currentSubScene}`);
            if (result.isPrefabEditMode !== undefined)
                lines.push(`- **Prefab Edit Mode:** ${result.isPrefabEditMode}`);
            if (result.boundsMin || result.boundsMax) {
                lines.push(`- **Terrain Bounds:** ${result.boundsMin || "?"} to ${result.boundsMax || "?"}`);
            }
            if (result.message)
                lines.push(`\n${result.message}`);
            return { content: [{ type: "text", text: lines.join("\n") }] };
        }
        catch (e) {
            const msg = e instanceof Error ? e.message : String(e);
            return {
                content: [
                    {
                        type: "text",
                        text: `Error getting Workbench state: ${msg}`,
                    },
                ],
            };
        }
    });
}
//# sourceMappingURL=wb-state.js.map